#include #include #include using namespace std; int N,K; int main(){ cin >> N >> K; int ma = -1; if(N==0 && K==0){ cout << "INF" << endl; return 0; } for(int i=0;i<30;i++) if(N&(1<=(1<<(ma+1))){ cout << "INF" << endl; return 0; } int a = ceil(log2(K)); int ans = 0; for(int i=0;i<=N+(1<<(a+2));i++){ for(int j=0;j<=K;j++){ if((i & (i+j))==N) ans++; } } cout << ans << endl; }