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