#include <bits/stdc++.h>
using namespace std;
int GCD(int a, int b) {
  if (a == 0)
    return b;
  else
    return GCD(b % a, a);
}
int main() {
  int v[2], n, i = 0;
  cin >> v[0] >> v[1] >> n;
  while (n >= 0) {
    int k = GCD(n, v[i]);
    n -= k;
    i = !i;
  }
  cout << i << endl;
}
