#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <bitset>
#include <cassert>
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;
}