#include <bits/stdc++.h>
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int main() {
  int a, b, n;
  bool isan = 0;
  scanf("%d %d %d", &a, &b, &n);
  while (n) n -= gcd(n, isan ? b : a), isan = !isan;
  printf("%d\n", !isan);
}
