#include <bits/stdc++.h>
using namespace std;
vector<int> divisors(int n) {
  vector<int> ret;
  ret.push_back(1);
  if (n > 1) ret.push_back(n);
  int i = 2;
  while (i * i < n) {
    if (n % i == 0) ret.push_back(i), ret.push_back(n / i);
    ++i;
  }
  if (i * i == n) ret.push_back(i);
  return ret;
}
int main() {
  int a, b;
  scanf("%d %d", &a, &b);
  if (a < b) {
    puts("0");
  } else if (a == b) {
    puts("infinity");
  } else {
    vector<int> divs = divisors(a - b);
    int ans = 0;
    for (const auto& div : divs)
      if (div > b) ++ans;
    printf("%d", ans);
  }
  return 0;
}
