#include <bits/stdc++.h>
using namespace std;
int gcd(int a, int b) {
  int c;
  while (a != 0) {
    c = a;
    a = b % a;
    b = c;
  }
  return b;
}
int main() {
  int a, b, n;
  cin >> a >> b >> n;
  while (1) {
    int x = gcd(a, n);
    if (x > n) {
      cout << 1 << '\n';
      break;
    }
    if (x <= n) {
      n -= x;
    }
    int y = gcd(b, n);
    if (y > n) {
      cout << 0 << '\n';
      break;
    }
    if (y <= n) {
      n -= y;
    }
  }
  return 0;
}
