#include <bits/stdc++.h>
using namespace std;
int gcd(int a, int b) {
  int t, r1, r2;
  for (r1 = a, r2 = b; t = r1 % r2; r1 = r2, r2 = t)
    ;
  return r2;
}
int main() {
  int a, b, n;
  cin >> a >> b >> n;
  while (1) {
    if (n) {
      n -= gcd(n, a);
    } else {
      cout << 1 << endl;
      break;
    }
    if (n) {
      n -= gcd(n, b);
    } else {
      cout << 0 << endl;
      break;
    }
  }
  return 0;
}
