#include <bits/stdc++.h>
using namespace std;
using namespace std;
int a[3], k = 0;
int gcd(int a, int b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
int main() {
  int j = 0, p, q, cou = 0;
  int a[3];
  cin >> a[0] >> a[1] >> a[2];
  p = a[0];
  q = a[2];
  cou = 1;
  while (q >= gcd(p, q)) {
    q = q - gcd(p, q);
    cou++;
    if (cou % 2 == 0) {
      p = a[1];
    } else {
      p = a[0];
    }
  }
  if (cou % 2 == 0) {
    cout << 0;
  } else {
    cout << 1;
  }
}
