#include <bits/stdc++.h>
using namespace std;
int gcd(int a, int b);
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int a, b, n;
  cin >> a >> b >> n;
  for (int i = 0; 1; i++) {
    if (i % 2 == 0) {
      if (n == 0) {
        cout << 1 << endl;
        break;
      } else {
        n -= gcd(a, n);
      }
    } else {
      if (n == 0) {
        cout << 0 << endl;
        break;
      } else {
        n -= gcd(b, n);
      }
    }
  }
  return 0;
}
int gcd(int a, int b) {
  int m, n;
  m = a;
  n = b;
  while (m != n) {
    if (m > n) {
      m = m - n;
    } else {
      n = n - m;
    }
  }
  return m;
}
