N,K = map(int,input().split()) import sys if N <= K: print('INF') exit() n = 1 while n < N: n <<= 1 ans = 0 for x in range(n+1): for y in range(x,x+K+1): if x & y == N:ans += 1 print(ans)