#include #include #include #include #include #include #include #include #include #include #include #include using namespace std; using ll = long long; int main() { int n, k; cin >> n >> k; ll ans = 0; int ma = 0; for (int x = 0; x < 3000000; x++) { for (int y = max(0, x - k); y <= x; y++) { if ((x&y) == n) ans++, ma = max(ma, x); } } if (ma >= 2000000) cout << "INF" << endl; else cout << ans << endl; return 0; }