import sys


def main():
    position = 0
    depth = 0
    aim = 0

    for line in sys.stdin:
        command, x_str = line.split()
        x = int(x_str)

        if command == "forward":
            position += x
            depth += aim * x
        elif command == "down":
            aim += x
        elif command == "up":
            aim -= x

    print(position * depth)


if __name__ == "__main__":
    main()
