#include <bits/stdc++.h>
using namespace std;
int gcd(int a, int b) {
  while (b) {
    int temp = b;
    b = a % b;
    a = temp;
  }
  return a;
}
int main() {
  int a, b, n, counting = 0, GCD;
  scanf("%d %d %d", &a, &b, &n);
  while (1) {
    counting++;
    GCD = gcd(a, n);
    if (n < GCD) break;
    n = n - GCD;
    counting++;
    GCD = gcd(b, n);
    if (n < GCD) break;
    n = n - GCD;
  }
  printf("%d\n", counting % 2);
  return 0;
}
