#include <bits/stdc++.h>
using namespace std;
int main() {
  int a = 0, b = 0;
  cin >> a >> b;
  if (a < b) {
    cout << 0;
    return 0;
  }
  if (a >= b) {
    int num = a - b;
    if (num == 0) {
      cout << "infinity";
      return 0;
    }
    int ret = 0;
    int i = 1;
    for (i = 1; i * i < num; i++) {
      if (num % i == 0) {
        if (a % i == b) {
          ret++;
        }
        if (a % (num / i) == b) {
          ret++;
        }
      }
    }
    int sq = sqrt(num);
    if (a != 2 && a % sq == b && num % sq == 0) {
      ret++;
    }
    cout << ret;
  }
  return 0;
}
