#include <bits/stdc++.h>
using namespace std;
int gcd(int a, int b) {
  if (b == 0)
    return a;
  else
    return gcd(b, a % b);
}
int main() {
  std::ios::sync_with_stdio(false);
  int a, b, n;
  cin >> a >> b >> n;
  int counter = 1;
  while (n != 0) {
    if (counter & 1) {
      n -= gcd(n, a);
      counter++;
    } else {
      n -= gcd(n, b);
      counter++;
    }
  }
  if (counter & 1)
    cout << "1" << '\n';
  else
    cout << "0" << '\n';
  return 0;
}
