#include <bits/stdc++.h>
using namespace std;
int Set(int N, int pos) { return N = N | (1 << pos); }
int reset(int N, int pos) { return N = N & ~(1 << pos); }
bool check(int N, int pos) { return (bool)(N & (1 << pos)); }
int main() {
  long long n, m, k, b, a, c, i, x, y, sum;
  while (scanf("%lld%lld", &a, &b) == 2) {
    if (b == a)
      printf("infinity\n");
    else if (b > a)
      printf("0\n");
    else {
      x = a - b;
      c = sqrt(x);
      n = 0;
      for (i = 1; i <= c; i++) {
        if (x % i == 0) {
          if (a % i == b) n++;
          if (a % (x / i) == b && x / i != i) n++;
        }
      }
      printf("%lld\n", n);
    }
  }
  return 0;
}
