#include <bits/stdc++.h>
using namespace std;
int a, b, ans;
bool prim(int x) {
  if (x == 1) return false;
  for (int i = 2; i * i <= x; i++)
    if (x % i == 0) return false;
  return true;
}
int f(int x) {
  int num = 0;
  for (int i = 1; i <= sqrt(x); i++) {
    if (x % i == 0 && a % i == b) ++num;
    if ((x / i) * i == x && (i * i) != x && x % (x / i) == 0 &&
        a % (x / i) == b)
      ++num;
  }
  return num;
}
int main() {
  scanf("%d %d", &a, &b);
  if (b > a)
    printf("%d\n", 0);
  else if (b == a)
    printf("infinity\n");
  else
    printf("%d\n", f(a - b));
  return 0;
}
