#include <bits/stdc++.h>
using namespace std;
int gcd_1(int a, int b) {
  if (b == 0) return a;
  return gcd_1(b, a % b);
}
int main() {
  int a, b, n;
  cin >> a >> b >> n;
  while (true) {
    int ta = gcd_1(a, n);
    n -= ta;
    if (n <= 0) {
      cout << "0";
      return 0;
    }
    int tb = gcd_1(b, n);
    n -= tb;
    if (n <= 0) {
      cout << "1";
      return 0;
    }
  }
  return 0;
}
