#include <bits/stdc++.h>
using namespace std;
int gcd(int a, int b);
int main() {
  int a, b, n, k = 1;
  bool l = false;
  cin >> a >> b >> n;
  while (l == false) {
    if (k % 2 != 0 && n >= gcd(n, a)) {
      k++;
      n -= gcd(n, a);
    } else if (k % 2 == 0 && n >= gcd(n, b)) {
      k++;
      n -= gcd(n, b);
    } else
      l = true;
  }
  if (k % 2 == 0) cout << "0";
  if (k % 2 != 0) cout << "1";
}
int gcd(int a, int b) {
  int c;
  while (a % b != 0) {
    c = a;
    a = b;
    b = c % b;
  }
  return b;
}
