#include <bits/stdc++.h>
using namespace std;
int gcd(int a, int b) {
  if (b == 0) return a;
  gcd(b, a % b);
}
int main() {
  int s = 0, a[2], n, k;
  cin >> a[0] >> a[1] >> n;
  while ((k = gcd(a[s], n)) < n) {
    n -= k;
    s = (!s);
  }
  printf("%d\n", s);
  return 0 * 0;
}
