#include <bits/stdc++.h>
using namespace std;
vector<unsigned long long int> vec;
void solve(unsigned long long int x) {
  unsigned long long int n = sqrt(x);
  for (int i = 1; i <= n; i++)
    if (x % i == 0)
      if (i == x / i)
        vec.push_back(i);
      else
        vec.push_back(x / i), vec.push_back(i);
}
int main() {
  cin.tie(0);
  std::ios::sync_with_stdio(false);
  unsigned long long int a, b;
  cin >> a >> b;
  if (a < b) {
    cout << 0 << endl;
    return 0;
  }
  if (a == b) {
    cout << "infinity\n";
    return 0;
  }
  unsigned long long int c = a - b, ans = 0;
  solve(c);
  sort(vec.begin(), vec.end());
  cout << vec.size() - (upper_bound(vec.begin(), vec.end(), b) - vec.begin())
       << endl;
  return 0;
}
