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