/*
威佐夫博奕(Wythoff Game) 两堆
对于这种博弈,有一个通项公式:a[k] = [k*(1+sqrt(5))/2],b[k] = a[k]+k;
基于两个规律.首先枚举前几个必败态
(0,0) (1,2) (3,5) (4,7) (6,10),....
规律是,a[k] = 等于之前没有出现的自然数
b[k] = a[k]+k
通项公式的给出,还有一个定理,beatty定理:
正无理数,alpha,beta,如果有1/a+1/b=1,那么数列[an],[bn],严格递增,而且构成正整数上的一个划分
a[n] = [cn]
b[n] = a[n]+n = [c*n] +n = [(c+1)n]
所以有 1/c+1/(c+1) = 1
解得,c=(1+sqrt(5))/2;
完毕
*/
// include file
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cctype>
#include <ctime>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <bitset>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <list>
#include <functional>
using namespace std;
// typedef
typedef __int64 LL;
//
#define read freopen("in.txt","r",stdin)
#define write freopen("out.txt","w",stdout)
#define Z(a,b) ((a)<<(b))
#define Y(a,b) ((a)>>(b))
const double eps = 1e-6;
const double INFf = 1e100;
const int INFi = 1000000000;
const LL INFll = (LL)1<<62;
const double Pi = acos(-1.0);
template<class T> inline T sqr(T a){return a*a;}
template<class T> inline T TMAX(T x,T y)
{
if(x>y) return x;
return y;
}
template<class T> inline T TMIN(T x,T y)
{
if(x<y) return x;
return y;
}
template<class T> inline T MMAX(T x,T y,T z)
{
return TMAX(TMAX(x,y),z);
}
template<class T> inline T MMIN(T x,T y,T z)
{
return TMIN(TMIN(x,y),z);
}
template<class T> inline void SWAP(T &x,T &y)
{
T t = x;
x = y;
y = t;
}
// code begin
int a,b;
int main()
{
read;
write;
int k,aa,bb;
while(scanf("%d %d",&a,&b)==2)
{
if(a>b) SWAP(a,b);
k = (int)(a*(sqrt(5.0)-1)/2);
aa = (int)(k*(1+sqrt(5.0))/2);
bb = aa+k;
if(aa==a && bb==b)
{
printf("0\n");
continue;
}
aa = (int)((k+1)*(1+sqrt(5.0))/2);
bb = aa+k+1;
if(aa==a && bb==b)
{
printf("0\n");
continue;
}
printf("1\n");
}
return 0;
}