#include <bits/stdc++.h>
using namespace std;
int gcd(int x, int y) {
  if (y == 0) return x;
  return gcd(y, x % y);
}
int main() {
  int x = 1, y = 1, heap = 100, gdid = 0;
  bool turn = 1, turn2 = 0;
  scanf("%d%d%d", &x, &y, &heap);
  while (1) {
    if (turn == 0)
      gdid = gcd(heap, y);
    else
      gdid = gcd(heap, x);
    if (gdid > heap) break;
    heap -= gdid;
    swap(turn, turn2);
  }
  printf("%d\n", turn);
  return 0;
}
