#include <bits/stdc++.h>
using namespace std;
int main() {
  int a, b, c;
  cin >> a >> b >> c;
  while (1) {
    int a1 = a, b1 = b, c1 = c;
    while (c1 != 0) {
      a1 %= c1;
      swap(a1, c1);
    }
    c -= a1;
    a1 = a;
    if (c == 0) {
      cout << 0;
      return 0;
    }
    c1 = c;
    while (c1 != 0) {
      b1 %= c1;
      swap(b1, c1);
    }
    c -= b1;
    if (c == 0) {
      cout << 1;
      return 0;
    }
  }
}
