import java.util.*;
import java.io.*;
import java.math.*;
class Ideone {
public static int gcd(int a, int b){
while(b != 0) b ^= a ^= b ^= a %= b;
return a;
}
public static void main
(String args
[]) { Scanner in
= new Scanner
(System.
in); int a = in.nextInt(); int b = in.nextInt();
int c = (a + b)/gcd(a, b);
System.
out.
println((a
== b
|| c
== (c
& (-c
))) ? 1 : 0); }
}
aW1wb3J0IGphdmEudXRpbC4qOwppbXBvcnQgamF2YS5pby4qOwppbXBvcnQgamF2YS5tYXRoLio7CiAKY2xhc3MgSWRlb25lIHsgCglwdWJsaWMgc3RhdGljIGludCBnY2QoaW50IGEsIGludCBiKXsKCQl3aGlsZShiICE9IDApIGIgXj0gYSBePSBiIF49IGEgJT0gYjsKCQlyZXR1cm4gYTsKCX0KICAgIHB1YmxpYyBzdGF0aWMgdm9pZCBtYWluKFN0cmluZyBhcmdzW10pIHsKICAgIAlTY2FubmVyIGluID0gbmV3IFNjYW5uZXIoU3lzdGVtLmluKTsKICAgIAlpbnQgYSA9IGluLm5leHRJbnQoKTsgaW50IGIgPSBpbi5uZXh0SW50KCk7CiAgICAJaW50IGMgPSAoYSArIGIpL2djZChhLCBiKTsKICAgIAlTeXN0ZW0ub3V0LnByaW50bG4oKGEgPT0gYiB8fCBjID09IChjICYgKC1jKSkpID8gMSA6IDApOwoJfQp9