import sys input = sys.stdin.readline N,K=map(int,input().split()) if N==0 and K!=0: print("INF") sys.exit() ANS=0 for x in range(N,2*10**5+1): for i in range(K+1): if x & (x+i)==N: ANS+=1 print(ANS)