#include <bits/stdc++.h>
using namespace std;
template <typename T>
inline T getNext() {
  T s = 1, x = 0, c = getc(stdin);
  while (c <= 32) c = getc(stdin);
  if (c == '-') s = -1, c = getc(stdin);
  while ('0' <= c && c <= '9') x = x * 10 + c - '0', c = getc(stdin);
  return x * s;
}
struct reader {
  template <typename T>
  reader& operator,(T& v) {
    v = getNext<T>();
    return *this;
  }
} rdr;
const double eps = 1e-9;
bool Equals(double x, double y) { return abs(x - y) < eps; }
bool Less(double x, double y) { return (x) < y - eps; }
bool LessOrEqual(double x, double y) { return (x) < y + eps; }
const int MaxN = int(1e5) + 256;
int main() {
  int a = getNext<int>(), b = getNext<int>();
  if (a == b) {
    puts("infinity");
    return 0;
  }
  int x = a - b, res = 0;
  for (int i = 1; i * i <= x; ++i) {
    if (x % i == 0) {
      int k = x / i;
      res += (i > b);
      res += (i != k && k > b);
    }
  }
  printf("%d\n", res);
  return 0;
}
