#include <bits/stdc++.h>
int nwd(int a, int b) {
  while (a * b) {
    if (a > b)
      a %= b;
    else
      b %= a;
  }
  return a + b;
}
int main() {
  int a[2], n, g = 0;
  std::cin >> a[0] >> a[1] >> n;
  while (n) {
    n -= nwd(a[g], n);
    g = (g + 1) % 2;
  }
  std::cout << (g + 1) % 2;
  return 0;
}
