#include <bits/stdc++.h>
int GCD(int a, int b) {
  if (b == 0)
    return a;
  else if (a == 0)
    return b;
  while (1) {
    if (a > b)
      a = a % b;
    else
      b = b % a;
    if (a == 0)
      return b;
    else if (b == 0)
      return a;
  }
}
int a, b, n;
int solve() {
  int turn = 0;
  while (1) {
    if (turn == 0) {
      if (n < GCD(a, n))
        return 1;
      else {
        n -= GCD(a, n);
        turn = 1;
      }
    } else {
      if (n < GCD(b, n))
        return 0;
      else {
        n -= GCD(b, n);
        turn = 0;
      }
    }
  }
}
int main() {
  scanf("%d %d %d", &a, &b, &n);
  printf("%d\n", solve());
  return 0;
}
