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