#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>

using namespace std;

#define int long long
#define rep(i,n) for(int i = 0; i < (n); i++)
#define INF ((long long)1e18)
#define MOD ((int)1e9+7)
#define endl "\n"

#define yn(f) ((f)?"Yes":"No")
#define YN(f) ((f)?"YES":"NO")

#define MAX 100

signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);
	
	int N, K;
	
	cin>>N>>K;
	
	if(N < K){
		cout<<"INF"<<endl;
	} else {
		int t = 1, ans = 0;
		for(int n = N; n;t <<= 1, n >>= 1);
		// cout<<t<<endl;
		for(int i = N; i < t; i++){
			for(int j = i; j - i <= K; j++){
				if((j&i) == N) ans++;
			}
		}
		
		cout<<ans<<endl;
	}
	
	return 0;
}