import sys input = sys.stdin.readline x,y=map(int,input().split()) ANS=0 for i in range(1000): if x|i==y: ANS+=1 print(ANS)