#include <bits/stdc++.h>
using namespace std;
int gcd(int n, int k) {
  int stones = n;
  while (k != 0) {
    int help = k;
    k = n % k;
    n = help;
  }
  return stones - n;
}
int main() {
  int a, b, n;
  cin >> a >> b >> n;
  bool simon = true;
  bool antisimon = true;
  int i = 0;
  while (simon && antisimon) {
    if (i % 2 == 0) {
      n = gcd(n, a);
      if (n < 0) simon = false;
    } else {
      n = gcd(n, b);
      if (n < 0) antisimon = false;
    }
    ++i;
  }
  if (simon)
    cout << 0;
  else
    cout << 1;
  return 0;
}
