#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, i, x, a, b, result = 0, t, w;
  cin >> a >> b >> n;
  for (t = 1; n >= 0; t++) {
    for (i = n; i >= 1; i--) {
      if (n % i == 0 && a % i == 0) {
        x = i;
        break;
      }
    }
    n = n - x;
    if (n == 0) {
      result = 0;
    }
    for (w = n; w >= 1; w--) {
      if (n % w == 0 && b % w == 0) {
        x = w;
        break;
      }
    }
    n = n - x;
    if (n == 0) {
      result = 1;
    }
  }
  cout << result;
}
