#include <bits/stdc++.h>
using namespace std;
bool not_prime[100000];
long long int primes[100000];
int p, prime_factors[100000], pf_count[100000], q;
int a[10000];
void find_primes() {
  long long int i, j;
  p = 0;
  for (i = 2; i < 100000; i++) {
    if (not_prime[i] == false) {
      primes[p++] = i;
      for (j = 2; i * j < 100000; j++) {
        not_prime[i * j] = false;
      }
    }
  }
}
void factor(long long int n) {
  q = 0;
  for (int i = 0; i < p; i++) {
    int count = 0;
    while (n % primes[i] == 0) {
      count++;
      n /= primes[i];
    }
    if (count > 0) {
      prime_factors[q] = i;
      pf_count[q++] = count;
    }
  }
  if (n > 1) {
    primes[p++] = n;
    prime_factors[q] = p - 1;
    pf_count[q++] = 1;
  }
}
int rec(int d, long long int b) {
  int ret = 0;
  if (d == q) {
    long long int x = 1;
    for (int i = 0; i < q; i++) {
      for (int j = 0; j < a[i]; j++) x *= primes[prime_factors[i]];
    }
    if (x <= b)
      return 0;
    else
      return 1;
  }
  for (int j = pf_count[d]; j >= 0; j--) {
    a[d] = j;
    int tmp = rec(d + 1, b);
    if (tmp == 0) break;
    ret += tmp;
  }
  return ret;
}
int main() {
  long long int a, b, n;
  int ans = 0;
  cin >> a >> b;
  n = a - b;
  if (a == b) {
    cout << "infinity" << endl;
  } else if (a < b) {
    cout << 0 << endl;
  } else {
    find_primes();
    factor(n);
    cout << rec(0, b) << endl;
  }
}
