#include <bits/stdc++.h>
using namespace std;
int gcd(int a, int b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
int main() {
  int a, b, n;
  bool simon = true, anti = false;
  cin >> a >> b >> n;
  while (true) {
    if (simon) {
      if (n == 0) {
        cout << 1 << endl;
        return 0;
      }
      n -= gcd(a, n);
      if (n < 0) {
        cout << 1 << endl;
        return 0;
      }
      simon = false;
      anti = true;
    } else {
      if (n == 0) {
        cout << 0 << endl;
        return 0;
      }
      n -= gcd(b, n);
      if (n < 0) {
        cout << 0 << endl;
        return 0;
      }
      simon = true;
      anti = false;
    }
  }
  return 0;
}
