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