#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 argc, char *argv[]) {
  int stones;
  int num[2];
  int p = 0;
  cin >> num[0];
  cin >> num[1];
  cin >> stones;
  while (1) {
    int take = gcd(num[p], stones);
    if (stones < take) {
      cout << (!p);
      return 0;
    }
    stones -= take;
    p = !p;
  }
  return 0;
}
