#include <bits/stdc++.h>
using namespace std;
long k, a, b, t, r, s = 0, n;
long GCD(long x, long y) {
  long j;
  while (y != 0) {
    j = x % y;
    x = y;
    y = j;
  }
  return x;
}
int main() {
  cin >> a >> b >> n;
  k = 0;
  while (n > 0) {
    if (k % 2)
      n = n - GCD(b, n);
    else
      n = n - GCD(a, n);
    if (n < 1)
      break;
    else
      k++;
  }
  cout << k % 2 << endl;
}
