#include <cstdio>
using namespace std;
inline int gcd(int a, int b){
while(b) b ^= a ^= b ^= a %= b;
return a;
}
int main()
{
int a, b, c;
scanf("%d %d", &a, &b);
c = (a + b)/gcd(a, b);
printf("%d\n", (a == b || c == (c & (-c))));
return 0;
}
I2luY2x1ZGUgPGNzdGRpbz4KdXNpbmcgbmFtZXNwYWNlIHN0ZDsKCmlubGluZSBpbnQgZ2NkKGludCBhLCBpbnQgYil7CiAgICB3aGlsZShiKSBiIF49IGEgXj0gYiBePSBhICU9IGI7CiAgICByZXR1cm4gYTsKfQoKaW50IG1haW4oKQp7CiAgICBpbnQgYSwgYiwgYzsKICAgIHNjYW5mKCIlZCAlZCIsICZhLCAmYik7CiAgICBjID0gKGEgKyBiKS9nY2QoYSwgYik7CiAgICBwcmludGYoIiVkXG4iLCAoYSA9PSBiIHx8IGMgPT0gKGMgJiAoLWMpKSkpOwogICAgcmV0dXJuIDA7Cn0K