#include <bits/stdc++.h>
using namespace std;
int main() {
  int a, b, x = 0;
  cin >> a >> b;
  int m = a - b;
  if (a == b) {
    cout << "infinity";
    return 0;
  }
  for (int i = 1; i <= sqrt((double)m); i++) {
    if (m % i == 0) {
      if (a % i == b) x++;
      if (m / i > sqrt(double(m)))
        if (a % (m / i) == b) x++;
    }
  }
  cout << x;
}
