#include <bits/stdc++.h>
using namespace std;
int main() {
  int a, b, n, p = 0;
  cin >> a >> b >> n;
  while (n > 0) {
    if (p % 2 == 0) {
      for (int i = a; i >= 1; i--)
        if (n % i == 0 && a % i == 0) {
          n -= i;
          p++;
          break;
        }
    } else {
      for (int i = b; i >= 1; i--)
        if (n % i == 0 && b % i == 0) {
          n -= i;
          p++;
          break;
        }
    }
  }
  ((p - 1) % 2 == 0) ? cout << "0" : cout << "1";
}
