#include <bits/stdc++.h>
using namespace std;
int gcd(int x, int y) {
  int i, g = 1;
  int min = (x > y) ? y : x;
  for (i = 1; i <= min; i++) {
    if (x % i == 0 && y % i == 0) g = i;
  }
  return g;
}
int main() {
  int a, b, n;
  cin >> a >> b >> n;
  int c = 0;
  int d = gcd(a, n);
  while (d <= n) {
    n = n - d;
    c++;
    if (c % 2 == 1) d = gcd(b, n);
    if (c % 2 == 0) d = gcd(a, n);
  }
  if (c % 2 == 1)
    cout << "0";
  else
    cout << "1";
  return 0;
}
