#include <bits/stdc++.h>
using namespace std;
int a, b, n, ans;
int main() {
  scanf("%d%d", &a, &b);
  n = a + b;
  if (a == 0 || b == 0) {
    printf("1");
    return 0;
  }
  for (int i = 1, j; i <= n; i = j) {
    int x = n / i;
    j = n / x + 1;
    int la = (a + x) / (x + 1), ra = a / x, lb = (b + x) / (x + 1), rb = b / x;
    if (la > ra || lb > rb) continue;
    la += lb, ra += rb;
    la = max(la, i), ra = min(ra, j - 1), ans += ra - la + 1;
  }
  printf("%d", ans);
  return 0;
}
