N,K = map(int,input().split()) ans = 0 if N == 0 and K ==0: print(1) exit() if N == 0 and 0 < K: print('INF') exit() cnt = 0 for i in range(K+1): for j in range(i,K+1): x = i+N y = j+N if x & y == N: cnt += 1 if not (len(bin(x)) == len(bin(y))): print('INF') exit() print(cnt)