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(2*N): for j in range(0,K+1): x = i y = i+j if x & y == N: cnt += 1 if not (len(bin(x)) == len(bin(y))): print('INF') exit() print(cnt)