#include <bits/stdc++.h>
int main() {
  int a, b;
  std::cin >> a >> b;
  const int n = a + b;
  int res = 0;
  for (int l = 1; l <= n;) {
    const int g = n / l, r = n / g;
    const int a_min = (a + g) / (g + 1), a_max = a / g,
              b_min = (b + g) / (g + 1), b_max = b / g;
    if (a_min <= a_max and b_min <= b_max)
      res += std::min(r, a_max + b_max) - std::max(l, a_min + b_min) + 1;
    l = r + 1;
  }
  std::cout << res << '\n';
}
