#include <bits/stdc++.h>   using namespace std;   int gcd(int a, int b) { return b == 0 ? a : gcd(b, a % b); }   int main() {     int a, b, h;     cin >> a >> b >> h;     int c = 0;     while (h != 0) {       if (c % 2 == 0) {         h = h - gcd(a, h);       } else {         h = h - gcd(b, h);       }       c++;     }     if (c % 2 == 0) {       cout << 1 << endl;     } else       cout << 0 << endl;   }   