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