#include <bits/stdc++.h>
using namespace std;
int gcd(int a, int b) {
  while (b) {
    a %= b;
    swap(a, b);
  }
  return a;
}
int main(int argc, char const *argv[]) {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int a, b, n;
  cin >> a >> b >> n;
  while (1) {
    n -= gcd(a, n);
    if (n == 0) {
      cout << "0\n";
      break;
    }
    n -= gcd(b, n);
    if (n == 0) {
      cout << "1\n";
      break;
    }
  }
}
