#!/usr/bin/env python3 lines = (x.strip() for x in open("input.txt")) hor = 0 depth = 0 for line in lines: cmd, strVal = line.split(" ") val = int(strVal) if cmd == 'forward': hor += val elif cmd == 'down': depth += val else: depth -= val print(hor*depth)