#include <bits/stdc++.h>
int main() {
  int gcd(int x, int y);
  int a, b, n, i;
  scanf("%d %d %d", &a, &b, &n);
  for (i = 1;; i++) {
    if (n < gcd(a, n)) {
      putchar('1');
      break;
    } else
      n = n - gcd(a, n);
    if (n < gcd(b, n)) {
      putchar('0');
      break;
    } else
      n = n - gcd(b, n);
  }
  return 0;
}
int gcd(int x, int y) {
  int m;
  while (x != y) {
    if (x < y) {
      m = x;
      x = y;
      y = m;
    }
    if (y == 0)
      break;
    else
      x = x - y;
  }
  return x;
}
