#include <bits/stdc++.h>
using namespace std;
int gcd(int a, int b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
void solve() {
  int a, b, n;
  cin >> a >> b >> n;
  bool aturn = true;
  while (n > 0) {
    int x;
    if (aturn) {
      x = gcd(a, n);
      aturn = false;
    } else {
      x = gcd(b, n);
      aturn = true;
    }
    n -= x;
  }
  if (aturn == false)
    cout << "0"
         << "\n";
  else
    cout << "1"
         << "\n";
}
int main(void) {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  solve();
  return 0;
}
