#include <bits/stdc++.h>
int ucln(int a, int b) {
  while (a != b) {
    if (a > b)
      a -= b;
    else
      b -= a;
  };
  return a;
}
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  long long n, a, b;
  int kt;
  cin >> a >> b >> n;
  while (true) {
    n -= ucln(a, n);
    if (n < 0) {
      kt = 1;
      break;
    } else if (n == 0) {
      kt = 0;
      break;
    };
    n -= ucln(b, n);
    if (n < 0) {
      kt = 0;
      break;
    } else if (n == 0) {
      kt = 1;
      break;
    };
  };
  cout << kt;
  return 0;
}
