#include <bits/stdc++.h>
using namespace std;
inline long long int inp() {
  long long int n = 0, s = 1;
  char c = getchar();
  while (c < '0') {
    if (c == '-') s = -1;
    c = getchar();
  }
  while (c <= '9' && c >= '0') n = (n << 3) + (n << 1) + c - '0', c = getchar();
  return n * s;
}
int a, b, n, g, ans = 1;
int gcd(int x, int y) {
  if (x == 0)
    return y;
  else
    return gcd(y % x, x);
}
int main() {
  a = inp(), b = inp(), n = inp();
  while (1) {
    if (ans == 1)
      g = gcd(a, n);
    else
      g = gcd(b, n);
    if (g > n) break;
    n -= g, ans ^= 1;
  }
  printf("%d\n", ans);
  return 0;
}
