#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
using namespace std;
#define sf scanf
#define pf printf
typedef long long ll;
int gcd(int a, int b)
{
if(b==0)
{
return a;
}
return gcd(b, a%b);
}
int main()
{
int a, b, n;
sf("%d%d%d", &a, &b, &n);
while(1)
{
n= n-gcd(a, n);
if(n<=0)
{
pf("0\n");
break;
}
n= n-gcd(b, n);
if(n<=0)
{
pf("1\n");
break;
}
}
}
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
using namespace std;
#define sf scanf
#define pf printf
typedef long long ll;
int gcd(int a, int b)
{
if(b==0)
{
return a;
}
return gcd(b, a%b);
}
int main()
{
int a, b, n;
sf("%d%d%d", &a, &b, &n);
while(1)
{
n= n-gcd(a, n);
if(n<=0)
{
pf("0\n");
break;
}
n= n-gcd(b, n);
if(n<=0)
{
pf("1\n");
break;
}
}
}