def _update_list(santa, cha):
    if cha == "^":
        santa[1] += 1
    elif cha == ">":
        santa[0] += 1
    elif cha == "v":
        santa[1] -= 1
    elif cha == "<":
        santa[0] -= 1

def part1(line):
    places_visited = set()
    santa = [0, 0]

    places_visited.add((santa[0], santa[1]))
    for cha in line:
        _update_list(santa, cha)
        places_visited.add((santa[0], santa[1]))
    
    return len(places_visited)

def part2(lines):
    places_visited = set()
    santa = [0,0]
    robo = [0,0]

    places_visited.add((0, 0))
    turn = "santa"
    for cha in line:
        if turn == "santa":
            _update_list(santa, cha)
            places_visited.add((santa[0], santa[1]))
            turn = "robo"
        elif turn == "robo":
            _update_list(robo, cha)
            places_visited.add((robo[0], robo[1]))
            turn = "santa"
    return len(places_visited)

if __name__ == "__main__":
    with open("../input.txt") as file:
        line = file.readlines()[0]

    print(part1(line))
    print(part2(line))
def _update_list(santa, cha):
    if cha == "^":
        santa[1] += 1
    elif cha == ">":
        santa[0] += 1
    elif cha == "v":
        santa[1] -= 1
    elif cha == "<":
        santa[0] -= 1

def part1(line):
    places_visited = set()
    santa = [0, 0]

    places_visited.add((santa[0], santa[1]))
    for cha in line:
        _update_list(santa, cha)
        places_visited.add((santa[0], santa[1]))
    
    return len(places_visited)

def part2(lines):
    places_visited = set()
    santa = [0,0]
    robo = [0,0]

    places_visited.add((0, 0))
    turn = "santa"
    for cha in line:
        if turn == "santa":
            _update_list(santa, cha)
            places_visited.add((santa[0], santa[1]))
            turn = "robo"
        elif turn == "robo":
            _update_list(robo, cha)
            places_visited.add((robo[0], robo[1]))
            turn = "santa"
    return len(places_visited)

if __name__ == "__main__":
    with open("../input.txt") as file:
        line = file.readlines()[0]

    print(part1(line))
    print(part2(line))