#include <bits/stdc++.h>
using namespace std;
int a, b, ans;
int main() {
  scanf("%d%d", &a, &b);
  int len = a + b;
  for (int i = 1, r; i <= len; i = r + 1) {
    int P = len / i;
    r = len / P;
    if (P > a || P > b) continue;
    int a_low = (a + P) / (P + 1), a_high = a / P;
    int b_low = (b + P) / (P + 1), b_high = b / P;
    if (a_low <= a_high && b_low <= b_high)
      ans += min((a_high + b_high), r) - max((a_low + b_low), i) + 1;
  }
  printf("%d ", ans);
  return 0;
}
