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