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