#include <bits/stdc++.h>
using namespace std;
int gcd(int a, int b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
int main() {
  int a, b, n;
  cin >> a >> b >> n;
  int w = 1;
  while (n != 0) {
    if (w == 1) {
      n -= gcd(n, a);
    } else {
      n -= gcd(n, b);
    }
    w = 1 - w;
  }
  cout << w << endl;
}
