#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include template inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; } template inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; } const long long MAX = 5100000; const long long INF = 1LL << 60; const long long mod = 1000000007LL; //const long long mod = 998244353LL; using namespace std; typedef unsigned long long ull; typedef long long ll; int main() { /* cin.tie(nullptr); ios::sync_with_stdio(false); */ ll N, K; cin >> N >> K; if (N == 0) { if (K == 0) puts("1"); else puts("INF"); } else { ll id; for (ll i = 60; i >= 0; i--) { if (N >> i & 1) { id = i; break; } } ll full = 0; for (ll i = id; i >= 0; i--) { full += (1LL << i); } ll res = 0; for (ll i = N; i <= full; i++) { for (ll j = i; j <= i + K; j++) { if ((i & j) == N) res++; } } cout << res << endl; } return 0; }