#include <bits/stdc++.h>
using namespace std;
const int INF = INT_MAX;
const long long INFL = LLONG_MAX;
const int output_precision = 15;
const long double pi = acos(-1);
const bool debug = true;
long long A, B;
int main() {
  ios_base::sync_with_stdio(0);
  cout.precision(output_precision);
  cout << fixed;
  cout.tie(0);
  cin >> A >> B;
  if (A == B) {
    cout << "infinity" << '\n';
    return 0;
  }
  if (A < B) {
    cout << 0 << '\n';
    return 0;
  }
  long long diff = A - B;
  vector<long long> v;
  for (long long d = 1; d * d <= diff; d++)
    if (diff % d == 0) {
      v.push_back(d);
      v.push_back(diff / d);
    }
  sort(v.begin(), v.end());
  v.erase(unique(v.begin(), v.end()), v.end());
  int ans = 0;
  for (int(i) = 0, j1234 = v.size(); (i) < j1234; (i)++) {
    long long x = v[i];
    if (A % x == B) {
      ans++;
    }
  }
  cout << ans << '\n';
  return 0;
}
