#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
const long long N = 1e5 + 1;
const long long INF = 1e10;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  int a, b;
  cin >> a >> b;
  if (a < b) {
    cout << 0;
    return 0;
  }
  if (a == b) {
    cout << "infinity";
    return 0;
  }
  int ans = 0, n = a - b;
  for (int i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      if (a % i == b) ans++;
      if (i * i != n and a % (n / i) == b) ans++;
    }
  }
  cout << ans;
}
