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