#include <bits/stdc++.h>
using namespace std;
template <typename T>
inline void in(register T& a) {
  register char c = getchar();
  register T x = 0, f = 1;
  while (!isdigit(c)) {
    if (c == '-') f = -1;
    c = getchar();
  }
  while (isdigit(c)) {
    x = (x << 1) + (x << 3) + c - '0';
    c = getchar();
  }
  a = x * f;
}
long long a, b, n;
inline long long gcd(long long a, long long b) {
  return b == 0 ? a : gcd(b, a % b);
}
int main() {
  in(a), in(b), in(n);
  while (n) {
    n -= gcd(n, a);
    if (!n) {
      printf("0\n");
      return 0;
    }
    n -= gcd(n, b);
    if (!n) {
      printf("1\n");
      return 0;
    }
  }
  return 0;
}
