A, B = map(int, input().split()) ans = 0 for n in range(256): if A|n == B: ans += 1 print(ans)