#include <bits/stdc++.h>
using namespace std;
int a[2], n, out;
int gcd(int x, int z) {
  if (x < z) swap(x, z);
  int temp;
  while (z) {
    temp = x % z;
    x = z;
    z = temp;
  }
  return x;
}
void input() { cin >> a[0] >> a[1] >> n; }
void calc() {
  for (int i = 0; i < 100; i++) {
    if (n == 0) {
      out = i % 2;
      return;
    }
    n -= gcd(a[i % 2], n);
    cerr << n << endl;
  }
}
void output() {
  out++;
  out %= 2;
  cout << out << endl;
}
int main() {
  input();
  calc();
  output();
  return 0;
}
