#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() {
  int simon_num, antisimon_num, heap;
  bool IsSimon = true;
  cin >> simon_num >> antisimon_num >> heap;
  int num = simon_num;
  while (heap > 0) {
    heap -= gcd(num, heap);
    IsSimon = !IsSimon;
    if (IsSimon)
      num = simon_num;
    else
      num = antisimon_num;
  }
  if (IsSimon)
    cout << 1 << endl;
  else
    cout << 0 << endl;
}
