def part2(data):
    """Return x*y where (x, y) is the final submarine position.

    The submarine starts at (0, 0).
    Up/down decreases/increases the aim, which starts at 0.
    The forward n command increases x by n and y by aim * n.
    """
    x = y = aim = 0
    for command in data.splitlines():
        instruction, displacement = command.split()
        displacement = int(displacement)
        if instruction == 'forward':
            x += displacement
            y += aim * displacement
        elif instruction == 'up':
            aim -= displacement
        elif instruction == 'down':
            aim += displacement
    return x * y