#include #include #include #include #include #include #include #include #include #include #include #include using namespace std; #define REP(i, n) for(ll i = 0;i < n;i++) #define REPR(i, n) for(ll i = n;i >= 0;i--) #define FOR(i, m, n) for(ll i = m;i < n;i++) #define FORR(i, m, n) for(ll i = m;i >= n;i--) #define REPO(i, n) for(ll i = 1;i <= n;i++) #define ll long long #define INF (ll)1 << 60 #define MINF (-1 * INF) #define ALL(n) n.begin(),n.end() #define MOD 1000000007 #define P pair ll s[30]; ll n, m, now, ans, mx; vector list, l2; int main() { cin >> n >> m; ll nn = n; while (n > 0) { if (n % 2 == 1) { s[now] = 1; mx = now; } now++; n /= 2; } if (1 + n <= m) { cout << "INF" << endl; return 0; } REP(i, 11) { if (s[i] == 0)list.push_back(pow(2, i)); if (s[i] == 0)l2.push_back(pow(2, i)); } REP(i, 1ll << (ll)list.size()) { REP(k, 1ll << (ll)l2.size()) { bool ok = true; REP(j, l2.size()) { if (i & (1ll << j) and k & (1ll << j))ok = false; } if (!ok)break; ll s1 = 0, s2 = 0; REP(j, list.size()) { if (i & (1ll << j))s1 += list[j]; } REP(j, l2.size()) { if (k & (1ll << j))s2 += l2[j]; } if (s1 < s2)break; if (m >= abs(s1 - s2))ans++; } } cout << ans << endl; }