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