#include"bits/stdc++.h" using namespace std; using ll = long long; using ld = long double; using pii = pair<int, int>; using pll = pair<ll, ll>; #define FOR(k,m,n) for(ll (k)=(m);(k)<(n);(k)++) #define REP(i,n) FOR((i),0,(n)) #define WAITING(str) int str;std::cin>>str; #define DEBUGING(str) cout<< #str << " " str<<endl constexpr int INF = (1 << 30); constexpr ll INFL = (1ll << 60); constexpr ll MOD = 1000000007;// 10^9+7 int main() { ll N, K, res = 0, cnt = 0; cin >> N >> K; REP(x, N * 16 + 4e5)FOR(y, x, x + K + 1) { if ((x&y) == N) { //cerr << x << " " << y << endl; res++; if (x > N * 4 + 1e5)cnt++; } } cout << (cnt > 0 ? "INF" : to_string(res)) << endl; return 0; }