#include <bits/stdc++.h>
using namespace std;
int gcd(int a, int b) {
  if (b == 0)
    return a;
  else
    return gcd(b, a % b);
}
int main() {
  int a, b, n, krok = 0;
  cin >> a >> b >> n;
  bool podm = false;
  int g;
  while (n > 0) {
    if (krok % 2 == 0) {
      g = gcd(a, n);
      n -= g;
      podm = true;
    } else {
      g = gcd(b, n);
      n -= g;
      podm = false;
    }
    krok++;
  }
  if (podm)
    cout << "0" << endl;
  else
    cout << "1" << endl;
}
