#include <bits/stdc++.h>
int a, b;
int main() {
  while (~scanf("%d%d", &a, &b)) {
    int c = a - b;
    if (c == 0)
      puts("infinity");
    else {
      int ans = 0;
      if (c > 0) {
        int m = sqrt(c + 0.5);
        for (int i = 1; i <= m; i++)
          if (c % i == 0) {
            int x1 = i, x2 = c / i;
            if (a % x1 == b) ans++;
            if (x2 != x1 && a % x2 == b) ans++;
          }
      }
      printf("%d\n", ans);
    }
  }
  return 0;
}
