#include <bits/stdc++.h>
using namespace std;
int gcd(int a, int b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
int main() {
  int a, b, n, take;
  scanf("%d%d%d", &a, &b, &n);
  bool aPlaying = true;
  while (1) {
    if (aPlaying) {
      take = gcd(a, n);
      n -= take;
      if (n == 0) {
        printf("0\n");
        return 0;
      }
      if (n < 0) {
        printf("1\n");
        return 0;
      }
      aPlaying = false;
    } else {
      take = gcd(b, n);
      n -= take;
      if (n == 0) {
        printf("1\n");
        return 0;
      }
      if (n < 0) {
        printf("0\n");
        return 0;
      }
      aPlaying = true;
    }
  }
  return 0;
}
