#include <bits/stdc++.h>
using namespace std;
int i, j, n;
bool k, l;
int gcd(int a, int b) {
  if (b == 0)
    return a;
  else
    return gcd(b, a % b);
}
int main() {
  cin >> i >> j >> n;
  while (n != 0) {
    n = n - gcd(i, n);
    if (n == 0) {
      k = true;
      break;
    }
    n = n - gcd(j, n);
    if (n == 0) {
      l = true;
      break;
    }
  }
  if (k) cout << "0" << endl;
  if (l) cout << "1" << endl;
}
