#include <bits/stdc++.h>
using namespace std;
int hcf(int a, int b) {
  if (a == 0 || b == 0) return (a > b) ? a : b;
  if (b % a == 0)
    return a;
  else
    return (hcf(b % a, a));
}
int main() {
  int a, b, n, c = 0;
  scanf("%d %d %d", &a, &b, &n);
  while (1) {
    if ((n >= hcf(n, a)) && n != 0)
      n = n - hcf(n, a);
    else {
      c = 1;
      break;
    }
    if ((n >= hcf(n, b)) && n != 0)
      n = n - hcf(n, b);
    else {
      c = 2;
      break;
    }
  }
  if (c == 2)
    printf("0");
  else
    printf("1");
  return 0;
}
