#include <bits/stdc++.h>
using namespace std;
int GCD(int a1, int a2) {
  int min = ::min(a1, a2);
  int max = ::max(a1, a2);
  if (max % min != 0) return GCD(min, max % min);
  return min;
}
int main(int argc, const char* argv[]) {
  int a, b, n;
  cin >> a >> b >> n;
  int total = n;
  int temp;
  int i;
  for (i = 0; i < total; i++) {
    if (i % 2 == 0) {
      temp = a;
    } else {
      temp = b;
    }
    if (n > 0) {
      n = n - GCD(n, temp);
      if (n < 0) {
        break;
      }
    } else
      break;
  }
  if (i % 2 == 0) {
    cout << 1;
  } else {
    cout << 0;
  }
  return 0;
}
