#include <bits/stdc++.h>
using namespace std;
unsigned GCD(unsigned u, unsigned v) {
  while (v != 0) {
    unsigned r = u % v;
    u = v;
    v = r;
  }
  return u;
}
int main() {
  int a, b, n;
  bool turn = 0;
  cin >> a >> b >> n;
  while (n != 0) {
    if (turn == 0) {
      n -= GCD(a, n);
      turn = 1;
    } else {
      n -= GCD(b, n);
      turn = 0;
    }
  }
  cout << (!turn);
  return 0;
}
