#include using namespace std; using ll = long long; bool judgeINF(int n, int K) { return n + 1 <= K; } int main() { cin.tie(0); ios::sync_with_stdio(false); int n, K; cin >> n >> K; if (judgeINF(n, K)) { cout << "INF" << endl; return 0; } int idx = -1; for (int i = 0; i <= 20; i++) { if (n & (1 << i)) { idx = i; } } idx++; int lim = (1 << idx) - 1; ll ans = 0; for (int y = n; y <= lim; y++) { for (int x = max(y - K, 0); x <= y; x++) { if ((x & y) == n) ans++; } } cout << ans << endl; return 0; }