#include <bits/stdc++.h>
using namespace std;
int a[2], n, i, t, gcd(int, int);
int main() {
  cin >> a[0] >> a[1] >> n;
  for (i = 0;; i = 1 - i) {
    t = gcd(a[i], n);
    if (t > n) break;
    n -= t;
  }
  cout << 1 - i;
  return 0;
}
int gcd(int x, int y) {
  int r;
  for (; y;) {
    r = x % y;
    x = y;
    y = r;
  }
  return x;
}
