#include <bits/stdc++.h>
int gcd(int, int);
int main() {
  int flag, a, b, n;
  scanf("%d %d %d", &a, &b, &n);
  flag = 0;
  while (n >= 0) {
    if (flag == 0) {
      n = n - gcd(a, n);
      flag = 1;
      if (n < 0) printf("1\n");
    } else {
      n = n - gcd(b, n);
      flag = 0;
      if (n < 0) printf("0\n");
    }
  }
  return 0;
}
int gcd(int x, int y) {
  if (y == 0)
    return x;
  else
    return gcd(y, x % y);
}
