#include <bits/stdc++.h>
using namespace std;
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int main() {
  int n, a, b, c;
  cin >> a >> b >> n;
  while (true) {
    int c = gcd(a, n);
    if (c > n) {
      cout << 1;
      break;
    }
    n -= c;
    c = gcd(b, n);
    if (c > n) {
      cout << 0;
      break;
    }
    n -= c;
  }
  return 0;
}
