def solve_part_two(sequence: list) -> int:
    """
    Calculates the first frequency that occurs twice
    :param sequence: Python list of integer frequency changes
    :return: First repeated frequency
    """

    frequencies = {0}
    counter = 0
    current = 0
    while True:
        current += sequence[counter]
        if current in frequencies:
            break
        else:
            frequencies.add(current)
            counter += 1
            counter %= len(sequence)

    return current