#include <bits/stdc++.h>
using namespace std;
int nextInt() {
  int x = 0, p = 1;
  char c;
  do {
    c = getchar();
  } while (c <= 32);
  if (c == '-') {
    p = -1;
    c = getchar();
  }
  while (c >= '0' && c <= '9') {
    x = x * 10 + c - '0';
    c = getchar();
  }
  return x * p;
}
double nextDouble() {
  double x;
  scanf("%lf", &x);
  return x;
}
void answer(int x) {
  if (x == -1)
    puts("infinity");
  else
    printf("%d\n", x);
  exit(0);
}
vector<int> factorize(int x) {
  vector<int> res;
  for (int i = 1; i * i <= x; i++) {
    if (x % i == 0) res.push_back(i), res.push_back(x / i);
  }
  sort(res.begin(), res.end());
  res.erase(unique(res.begin(), res.end()), res.end());
  return res;
}
int main() {
  int a = nextInt();
  int b = nextInt();
  int c = a - b;
  if (c < 0) answer(0);
  if (c == 0) answer(-1);
  vector<int> f = factorize(c);
  int res = 0;
  for (size_t i = 0; i < f.size(); i++)
    if (f[i] > b) res++;
  answer(res);
  return 0;
}
