from os import readlink f = open ('input2.txt', 'r') input = f.readlines() forward = 0 depth = 0 for i in range(len(input)): input[i] = input[i].strip() for i in range(len(input)): direct, amount = input[i].split(" ", 1) if direct == 'forward': forward += int(amount) if direct == 'down': depth += int(amount) if direct == 'up': depth -= int(amount) x = depth * forward print(x)