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