#include <bits/stdc++.h>
using namespace std;
int a, b;
int main() {
  cin >> a >> b;
  int delta = abs(a - b);
  if (!delta)
    printf("infinity\n");
  else {
    int cnt = 0;
    int m = (int)sqrt(delta + 0.5);
    for (int i = 1; i <= m; i++)
      if (delta % i == 0)
        if (delta / i != i) {
          int x1 = delta / i, x2 = i;
          if (a % x1 == b) {
            cnt++;
          }
          if (a % x2 == b) {
            cnt++;
          }
        } else {
          int x = i;
          if (a % x == b) {
            cnt++;
          }
        }
    cout << cnt << endl;
  }
  return 0;
}
