#include <bits/stdc++.h>
using namespace std;
int gcd(int a, int b) {
  int g;
  for (int i = a; i >= 1; i--) {
    if (a % i == 0 && b % i == 0) {
      g = i;
      break;
    }
  }
  return g;
}
int main() {
  int a[2], n, c = 0;
  cin >> a[0] >> a[1] >> n;
  while (n >= gcd(a[c % 2], n)) {
    n -= gcd(a[c % 2], n);
    c++;
  }
  c--;
  if (c < 0) c = 0 - c;
  cout << c % 2 << endl;
}
