#include <bits/stdc++.h>
using namespace std;
int gcd(int x, int y) {
  int g = min(x, y);
  while (g != 1) {
    if ((x % g == 0) && (y % g == 0)) return g;
    g--;
  }
  return g;
}
int main() {
  int a, b, n, s = 1;
  cin >> a >> b >> n;
  while (n != 0) {
    if (s == 1) {
      s = 0;
      n -= gcd(n, a);
    } else {
      s = 1;
      n -= gcd(n, b);
    }
  }
  cout << s;
}
