#include <bits/stdc++.h>
using namespace std;
long long GCDFast(long long a, long long b) {
  while (b) b ^= a ^= b ^= a %= b;
  return a;
}
int dx[8] = {-1, 0, 1, 0, -1, 1, 1, -1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
long long GCD(long long b, long long a) {
  if (a == 0) return b;
  return GCD(a, b % a);
}
long long getLCM(long long a, long long b) {
  long long c = a / GCD(a, b);
  return b * c;
}
string s1, s2, s3;
int a[1000005];
char str[110][1111];
int main() {
  std::ios_base::sync_with_stdio(false);
  long long n, m, i, j, k, result = 0, temp, x = 0, y, z;
  long long flag, sum = 0, max, number, min;
  string str, s;
  while (cin >> x >> y >> n) {
    flag = 0;
    for (i = 1;; i++) {
      if (i & 1) {
        j = GCD(x, n);
        if (j > n) {
          flag = 1;
          break;
        }
        n = n - j;
        if (n == 0) {
          flag = 2;
          break;
        }
      } else {
        j = GCD(y, n);
        if (j > n) {
          flag = 2;
          break;
        }
        n = n - j;
        if (n == 0) {
          flag = 1;
          break;
        }
      }
    }
    if (flag == 2) cout << "0\n";
    if (flag == 1) cout << "1\n";
  }
  return 0;
}
