#include <bits/stdc++.h>
using namespace std;
int gcd(int a, int b) {
  int c;
  while (a != 0) {
    c = b % a;
    b = a;
    a = c;
  }
  return b;
}
int main() {
  int a, b, n, f, g, i;
  cin >> a >> b >> n;
  int temp = 0;
  for (i = 1;; i++) {
    if (i % 2 != 0) {
      f = gcd(a, n);
      if (f >= n) {
        temp = 0;
        break;
      } else {
        n -= f;
      }
    } else {
      g = gcd(b, n);
      if (g >= n) {
        temp = 1;
        break;
      } else {
        n -= g;
      }
    }
  }
  cout << temp << endl;
  return 0;
}
