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