#include <bits/stdc++.h>
using namespace std;
int ri() {
  int x;
  if (scanf(" %d", &x) == EOF) return -1;
  return x;
}
long long int rl() {
  long long int x;
  if (cin >> x) return x;
  return -1;
}
string rs() {
  string s;
  if (cin >> s) return s;
  return "";
}
struct SingleCase {
  long long int a, b;
  bool solveCase() {
    a = ri();
    if (a < 0) return false;
    b = ri();
    long long int n = a + b;
    long long int ret = 0;
    long long int count = 1;
    for (long long int period = 1; period <= n; count++) {
      long long int reps = n / period;
      long long int maxPeriod = min(n / reps, n);
      long long int k = reps;
      long long int lox = (a + k) / (k + 1), hix = a / k;
      long long int loy = (b + k) / (k + 1), hiy = b / k;
      if (lox <= hix && loy <= hiy) {
        long long int lo = lox + loy, hi = hix + hiy;
        ret += intersect(lo, hi, period, maxPeriod);
      }
      period = maxPeriod + 1;
    }
    cout << ret << endl;
    return true;
  }
  long long int intersect(long long int a, long long int b, long long int x,
                          long long int y) {
    long long int p = max(a, x), q = min(b, y);
    if (q >= p) return q - p + 1;
    return 0;
  }
};
int main() {
  while (SingleCase().solveCase()) {
  };
  return 0;
}

### Prompt

Create a solution in CPP for 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;
int ri() {
  int x;
  if (scanf(" %d", &x) == EOF) return -1;
  return x;
}
long long int rl() {
  long long int x;
  if (cin >> x) return x;
  return -1;
}
string rs() {
  string s;
  if (cin >> s) return s;
  return "";
}
struct SingleCase {
  long long int a, b;
  bool solveCase() {
    a = ri();
    if (a < 0) return false;
    b = ri();
    long long int n = a + b;
    long long int ret = 0;
    long long int count = 1;
    for (long long int period = 1; period <= n; count++) {
      long long int reps = n / period;
      long long int maxPeriod = min(n / reps, n);
      long long int k = reps;
      long long int lox = (a + k) / (k + 1), hix = a / k;
      long long int loy = (b + k) / (k + 1), hiy = b / k;
      if (lox <= hix && loy <= hiy) {
        long long int lo = lox + loy, hi = hix + hiy;
        ret += intersect(lo, hi, period, maxPeriod);
      }
      period = maxPeriod + 1;
    }
    cout << ret << endl;
    return true;
  }
  long long int intersect(long long int a, long long int b, long long int x,
                          long long int y) {
    long long int p = max(a, x), q = min(b, y);
    if (q >= p) return q - p + 1;
    return 0;
  }
};
int main() {
  while (SingleCase().solveCase()) {
  };
  return 0;
}

```