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