#include <bits/stdc++.h>
using namespace std;
int gcd(int a, int b) {
  while (b) {
    a %= b;
    swap(a, b);
  }
  return a;
}
int main() {
  int nums[2];
  int n;
  cin >> nums[0] >> nums[1] >> n;
  int player = 0;
  while (n > 0) {
    n -= gcd(n, nums[player]);
    player ^= 1;
  }
  if (n == 0) player ^= 1;
  cout << player;
  return 0;
}
