#include <bits/stdc++.h>
using namespace std;
unsigned int gcd(unsigned int x, unsigned int y) {
  unsigned int temp;
  if (x < y) {
    temp = x;
    x = y;
    y = temp;
  }
  for (unsigned int i = y; i > 0; i--) {
    if ((x % i == 0) && (y % i == 0)) return i;
  }
  return x;
}
int main() {
  int a, b, n;
  cin >> a >> b >> n;
  while (1) {
    n -= gcd(n, a);
    if (n < 0) {
      cout << "1";
      break;
    }
    n -= gcd(n, b);
    if (n < 0) {
      cout << "0";
      break;
    }
  }
  return 0;
}
