#include <bits/stdc++.h>
using namespace std;
int gcd(int a, int b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
void gcd_fun(int a, int b, int n) {
  int stone = n, num = a, value, temp;
  bool flag = true;
  int cnt = 0;
  while (flag == true) {
    value = gcd(num, stone);
    if (value <= stone) {
      stone = stone - value;
      temp = (num == a) ? b : a;
      num = temp;
      cnt++;
    } else
      flag = false;
  }
  if (cnt % 2 == 1)
    printf("0");
  else
    printf("1");
}
int main() {
  int a, b, n;
  scanf("%d%d%d", &a, &b, &n);
  gcd_fun(a, b, n);
}
