Simon and Antisimon play a game. Initially each player receives one fixed positive integer that doesn't change throughout the game. Simon receives number *a* and Antisimon receives number *b*. They also have a heap of *n* stones. The players take turns to make a move and Simon starts. During a move a player should take from the heap the number of stones equal to the greatest common divisor of the fixed number he has received and the number of stones left in the heap. A player loses when he cannot take the required number of stones (i. e. the heap has strictly less stones left than one needs to take). 

Your task is to determine by the given *a*, *b* and *n* who wins the game.
The only string contains space-separated integers *a*, *b* and *n* (1 ≤ *a*, *b*, *n* ≤ 100) — the fixed numbers Simon and Antisimon have received correspondingly and the initial number of stones in the pile.
3 5 9
0
1 1 100
1
23 12 16
1
95 26 29
1
73 32 99
1
1 1 1
0
41 12 65
1
13 61 100
1
100 100 10
0
12 24 26
1
73 21 96
1
17 22 81
1
14 88 97
1
42 81 17
0
34 36 19
1
21 87 12
1
97 92 98
1
49 25 62
1
29 17 44
1
10 1 10
0
99 98 100
1
100 100 1
0
11 99 55
0
8 13 21
0
34 55 89
0
21 34 55
1
13 21 34
1
34 21 55
0
10 20 84
1
4 2 5
0
3 2 3
0
31 23 1
0
100 100 100
0
100 1 100
0
1 100 100
1
1 1 100
1
17 23 100
1
99 98 100
1
1 1 2
1
2 1 1
0
1 2 1
0
2 1 2
0
10 10 3
1
2 2 1
0
9 5 1
0
def MaxDelit(chislo1, chislo2):
    min_del = min(chislo1, chislo2)
    while True:
        if chislo1 % min_del == 0 and chislo2 % min_del == 0:
            return min_del
        else:
            min_del -= 1


# all_stones = int(input())
# sem_stones = int(input())
# antisem_stones = int(input())

sem_stones, antisem_stones, all_stones = map(int, input().split())
chislo1 = sem_stones
chilso2 = antisem_stones


def game(player, all_stones, i=0):
    while antisem_stones < all_stones or sem_stones < all_stones:
        if i % 2 == 0:
            player = sem_stones
        else:
            player = antisem_stones
        raznost = MaxDelit(player, all_stones)
        all_stones -= raznost
        i += 1
    if i % 2 == 0:
        print('0')
    else:
        print('1')


game(sem_stones, all_stones)