#include <bits/stdc++.h>
using namespace std;
stringstream ss;
int dx[4] = {-1, 0, 1, 0};
int dy[4] = {0, -1, 0, 1};
template <class T>
int pyfind(const vector<T> &vect, const T &targ) {
  for (int i = 0; i < vect.size(); i++) {
    if (vect[i] == targ) return i;
  }
  return -1;
}
void remove(vector<int> &vect, int x) {
  vector<int>::iterator itr;
  itr = vect.begin();
  for (int i = 0; i < x; i++) {
    itr++;
  }
  vect.erase(itr);
}
int gcd(int a, int b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
int a, b, n;
int main() {
  cin >> a >> b >> n;
  while (1) {
    n -= gcd(a, n);
    if (n < 0) {
      cout << 1 << endl;
      break;
    }
    n -= gcd(b, n);
    if (n < 0) {
      cout << 0 << endl;
      break;
    }
  }
}
