#include <bits/stdc++.h>
using namespace std;
int main() {
  int a, b;
  scanf("%d %d", &a, &b);
  if (a == 0 || b == 0) {
    printf("%d\n", max(a, b));
  } else {
    int ans = 0;
    for (int i = 2; i <= a + b;) {
      int need = (a + b) / i;
      int aa = a / need;
      int bb = b / need;
      int aaa = (a + need) / (need + 1);
      int bbb = (b + need) / (need + 1);
      int r = min(aa + bb, (a + b) / need);
      int l = max(aaa + bbb, i);
      if (aaa > aa || bbb > bb)
        ;
      else
        ans += max(r - l + 1, 0);
      i = (a + b) / need + 1;
    }
    printf("%d\n", ans);
  }
  return 0;
}
