#include <bits/stdc++.h>
using namespace std;
int gcd(int x, int y) {
  if (y == 0)
    return x;
  else
    return gcd(y, x % y);
}
int main() {
  int n1 = 3, n2 = 5, heap = 9, tern = 0;
  cin >> n1 >> n2 >> heap;
  for (;;) {
    if (heap < gcd(heap, n2) || heap < gcd(heap, n1)) {
      break;
    }
    if (tern % 2 == 0) {
      heap = heap - gcd(heap, n1);
    } else {
      heap = heap - gcd(heap, n2);
    }
    tern++;
  }
  if (tern % 2 == 0) {
    cout << "1" << endl;
  } else {
    cout << "0" << endl;
  }
}
