#include <bits/stdc++.h>
using namespace std;
class ModEq {
 public:
  void start() {
    set<int> s;
    int a, b;
    scanf("%d %d", &a, &b);
    if (a == b) {
      printf("infinity\n");
      return;
    }
    int res = 0;
    int root = sqrt(a - b);
    if (root * root != (a - b)) root++;
    root++;
    for (int i = 1; i < root; i++) {
      if ((a - b) % i == 0) {
        int other = (a - b) / i;
        if (i > b) s.insert(i);
        if (other > b) s.insert(other);
      }
    }
    printf("%d\n", s.size());
  }
};
ModEq meq;
int main(int argc, char **argv) {
  meq.start();
  return 0;
}
