#include <bits/stdc++.h>
using namespace std;
int gcd(int x, int y) {
  int z = x % y;
  do {
    z = x % y;
    x = y;
    y = z;
  } while (z > 0);
  return x;
}
int main() {
  int n, m, k, t = 1;
  cin >> n >> m >> k;
  while (1) {
    if (t == 1) {
      if (k - gcd(max(n, k), min(n, k)) > 0) {
        k -= gcd(max(n, k), min(n, k));
        t = 0;
      } else {
        cout << "0";
        return 0;
      }
    } else {
      if (k - gcd(max(k, m), min(k, m)) > 0) {
        k -= gcd(max(k, m), min(k, m));
        t = 1;
      } else {
        cout << "1";
        return 0;
      }
    }
  }
  return 0;
}
