#include <bits/stdc++.h>
using namespace std;
int A, B, N;
void init() {
  scanf("%d", &A);
  scanf("%d", &B);
  scanf("%d", &N);
}
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
void solve() {
  bool turn = false;
  int arr[2] = {A, B};
  while (true) {
    int d = gcd(arr[turn], N);
    if (d > N) {
      printf("%d\n", !turn);
      break;
    }
    N -= d;
    turn = !turn;
  }
}
int main() {
  int C = 1;
  while (C--) {
    init();
    solve();
  }
  return 0;
}
