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