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