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