#include <bits/stdc++.h>
using namespace std;
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int main() {
  int a, b, n;
  cin >> a >> b >> n;
  while (true) {
    int tmpa = gcd(a, n);
    if (tmpa > n) {
      cout << 1;
      return 0;
    } else {
      n -= tmpa;
    }
    int tmpb = gcd(b, n);
    if (tmpb > n) {
      cout << 0;
      return 0;
    } else {
      n -= tmpb;
    }
  }
  return 0;
}
