#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, count = 1;
  cin >> a >> b >> n;
  while (n > 0) {
    if (count % 2 == 1)
      n = n - gcd(a, n);
    else
      n = n - gcd(b, n);
    count++;
  }
  if (count % 2 == 1)
    cout << "1";
  else
    cout << "0";
  return 0;
}
