#include <bits/stdc++.h>
using namespace std;
int a, b, x;
int main() {
  int res = 0;
  cin >> a >> b;
  if (a == b) {
    cout << "infinity";
    return 0;
  }
  for (int i = 1; i <= trunc(sqrt(a - b)); i++)
    if ((a - b) % i == 0) {
      int x1, x2;
      x1 = i;
      x2 = (a - b) / x1;
      if (a % x1 == b) res++;
      if (x1 != x2 && a % x2 == b) res++;
    }
  cout << res;
}
