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