#include <bits/stdc++.h>
using namespace std;
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
  cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << " : " << arg1 << " | ";
  __f(comma + 1, args...);
}
long long MODpow(long long input, long long n, long long difference) {
  long long res = 1, y = input;
  while (n > 0) {
    if (n & 1) res = (res * y) % difference;
    y = (y * y) % difference;
    n /= 2;
  }
  return res % difference;
}
template <class T>
T _abs(T n) {
  return (n < 0 ? -n : n);
}
template <class T>
T _max(T input, T b) {
  return (!(input < b) ? input : b);
}
template <class T>
T _min(T input, T b) {
  return (input < b ? input : b);
}
template <class T>
T gcd(T input, T b) {
  return (b != 0 ? gcd<T>(b, input % b) : input);
}
template <class T>
T lcm(T input, T b) {
  return (input / gcd<T>(input, b) * b);
}
inline int fi() {
  int n = 0;
  int ch = getchar();
  while (ch < '0' || ch > '9') ch = getchar();
  while (ch >= '0' && ch <= '9')
    n = (n << 3) + (n << 1) + ch - '0', ch = getchar();
  return n;
}
inline void fo(int input) {
  char snum[20];
  int iterator = 0;
  do {
    snum[iterator++] = input % 10 + 48;
    input = input / 10;
  } while (input != 0);
  iterator = iterator - 1;
  while (iterator >= 0) putchar(snum[iterator--]);
  putchar('\n');
}
int MOD = 1e9 + 7, INF = 1e9;
long long INFLL = 1e18;
long long unsigned INFLLU = 18446744073709551615ULL;
long double EPS = 1e-12;
inline int inv(int input, int p = MOD) { return MODpow(input, p - 2, p); }
inline int sign(long double x) { return x < -EPS ? -1 : x > +EPS; }
inline void addMOD(int& input, int val, int p = MOD) {
  if ((input = (input + val)) >= p) input -= p;
}
inline void subMOD(int& input, int val, int p = MOD) {
  if ((input = (input - val)) < 0) input += p;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int a, b;
  cin >> a >> b;
  int n = a + b;
  int ans = 0;
  int l = 1;
  while (l <= n) {
    int g = n / l;
    if (a < g || b < g) {
      l = n / g + 1;
      continue;
    }
    int r = n / g;
    int a_low = (a + g) / (g + 1);
    int a_high = a / g;
    int b_low = (b + g) / (g + 1);
    int b_high = b / g;
    if (a_low <= a_high && b_low <= b_high)
      ans += max(0, min(r, a_high + b_high) - max(l, a_low + b_low) + 1);
    l = r + 1;
  }
  cout << ans << endl;
  cerr << "Time elapsed :" << clock() * 1000.0 / CLOCKS_PER_SEC << " ms"
       << '\n';
  return 0;
}

### Prompt

Generate a Cpp solution to the following problem:

You are given a uppercase Latin letters 'A' and b letters 'B'.

The period of the string is the smallest such positive integer k that s_i = s_{i~mod~k} (0-indexed) for each i. Note that this implies that k won't always divide a+b = |s|.

For example, the period of string "ABAABAA" is 3, the period of "AAAA" is 1, and the period of "AABBB" is 5.

Find the number of different periods over all possible strings with a letters 'A' and b letters 'B'.

Input

The first line contains two integers a and b (1 ≤ a, b ≤ 10^9) — the number of letters 'A' and 'B', respectively.

Output

Print the number of different periods over all possible strings with a letters 'A' and b letters 'B'.

Examples

Input


2 4


Output


4


Input


5 3


Output


5

Note

All the possible periods for the first example: 

  * 3 "BBABBA" 
  * 4 "BBAABB" 
  * 5 "BBBAAB" 
  * 6 "AABBBB" 



All the possible periods for the second example: 

  * 3 "BAABAABA" 
  * 5 "BAABABAA" 
  * 6 "BABAAABA" 
  * 7 "BAABAAAB" 
  * 8 "AAAAABBB" 



Note that these are not the only possible strings for the given periods.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
  cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << " : " << arg1 << " | ";
  __f(comma + 1, args...);
}
long long MODpow(long long input, long long n, long long difference) {
  long long res = 1, y = input;
  while (n > 0) {
    if (n & 1) res = (res * y) % difference;
    y = (y * y) % difference;
    n /= 2;
  }
  return res % difference;
}
template <class T>
T _abs(T n) {
  return (n < 0 ? -n : n);
}
template <class T>
T _max(T input, T b) {
  return (!(input < b) ? input : b);
}
template <class T>
T _min(T input, T b) {
  return (input < b ? input : b);
}
template <class T>
T gcd(T input, T b) {
  return (b != 0 ? gcd<T>(b, input % b) : input);
}
template <class T>
T lcm(T input, T b) {
  return (input / gcd<T>(input, b) * b);
}
inline int fi() {
  int n = 0;
  int ch = getchar();
  while (ch < '0' || ch > '9') ch = getchar();
  while (ch >= '0' && ch <= '9')
    n = (n << 3) + (n << 1) + ch - '0', ch = getchar();
  return n;
}
inline void fo(int input) {
  char snum[20];
  int iterator = 0;
  do {
    snum[iterator++] = input % 10 + 48;
    input = input / 10;
  } while (input != 0);
  iterator = iterator - 1;
  while (iterator >= 0) putchar(snum[iterator--]);
  putchar('\n');
}
int MOD = 1e9 + 7, INF = 1e9;
long long INFLL = 1e18;
long long unsigned INFLLU = 18446744073709551615ULL;
long double EPS = 1e-12;
inline int inv(int input, int p = MOD) { return MODpow(input, p - 2, p); }
inline int sign(long double x) { return x < -EPS ? -1 : x > +EPS; }
inline void addMOD(int& input, int val, int p = MOD) {
  if ((input = (input + val)) >= p) input -= p;
}
inline void subMOD(int& input, int val, int p = MOD) {
  if ((input = (input - val)) < 0) input += p;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int a, b;
  cin >> a >> b;
  int n = a + b;
  int ans = 0;
  int l = 1;
  while (l <= n) {
    int g = n / l;
    if (a < g || b < g) {
      l = n / g + 1;
      continue;
    }
    int r = n / g;
    int a_low = (a + g) / (g + 1);
    int a_high = a / g;
    int b_low = (b + g) / (g + 1);
    int b_high = b / g;
    if (a_low <= a_high && b_low <= b_high)
      ans += max(0, min(r, a_high + b_high) - max(l, a_low + b_low) + 1);
    l = r + 1;
  }
  cout << ans << endl;
  cerr << "Time elapsed :" << clock() * 1000.0 / CLOCKS_PER_SEC << " ms"
       << '\n';
  return 0;
}

```