#include <bits/stdc++.h>
using namespace std;
int gcd(int a, int b) {
  int i;
  for (i = min(a, b); i != 0; --i) {
    if (max(a, b) % i == 0) {
      if (min(a, b) % i == 0) return i;
    }
  }
}
int main() {
  int a, b, n, o = 1, w;
  cin >> a >> b >> n;
  while (n > 0) {
    if (o % 2 != 0) {
      if (n >= gcd(a, n)) {
        n -= gcd(a, n);
        w = 0;
        ++o;
      }
    } else {
      if (n >= gcd(b, n)) {
        n -= gcd(b, n);
        w = 1;
        ++o;
      }
    }
  }
  if (w == 0)
    cout << "0";
  else
    cout << "1";
  return 0;
}
