#include <bits/stdc++.h>
using namespace std;
int gcd(int a, int b) {
  if (!a || !b) return max(a, b);
  while (a != b) {
    if (a > b) {
      a = a - b;
    } else {
      b = b - a;
    }
  }
  return a;
}
int main() {
  int a, b, n;
  cin >> a >> b >> n;
  while (true) {
    if (gcd(a, n) <= n)
      n -= gcd(a, n);
    else {
      puts("1");
      break;
    }
    if (gcd(b, n) <= n)
      n -= gcd(b, n);
    else {
      puts("0");
      break;
    }
  }
  return 0;
}
