#include <bits/stdc++.h>
using namespace std;
long long RAND(long long n) { return abs((rand() << 15) + rand()) % n; }
vector<vector<int>> go;
vector<int> out;
vector<int> f;
const int alphabet_size = 26;
void BuildMatchingMachine(vector<string> &arr) {
  int number_of_states = 0;
  for (auto &i : arr) {
    number_of_states += i.size();
  }
  go.resize(number_of_states + 1, vector<int>(alphabet_size, -1));
  out.resize(number_of_states + 1, 0);
  f.resize(number_of_states + 1, -1);
  int node = 1;
  for (int i = 0; i < arr.size(); ++i) {
    int current_node = 0;
    for (int j = 0; j < arr[i].size(); ++j) {
      if (go[current_node][arr[i][j] - 'a'] == -1)
        go[current_node][arr[i][j] - 'a'] = node++;
      current_node = go[current_node][arr[i][j] - 'a'];
    }
    out[current_node]++;
  }
  f[0] = 0;
  queue<int> Init_nodes;
  for (int c = 0; c < alphabet_size; ++c) {
    if (go[0][c] == -1) {
      go[0][c] = 0;
    }
    if (go[0][c] != 0) {
      Init_nodes.push(go[0][c]);
    }
    f[go[0][c]] = 0;
  }
  while (!Init_nodes.empty()) {
    int cur_node = Init_nodes.front();
    Init_nodes.pop();
    for (int c = 0; c < 26; ++c) {
      if (go[cur_node][c] != -1) {
        int failure = f[cur_node];
        while (go[failure][c] == -1) {
          failure = f[failure];
        }
        failure = go[failure][c];
        f[go[cur_node][c]] = failure;
        out[go[cur_node][c]] += out[failure];
        Init_nodes.push(go[cur_node][c]);
      }
    }
  }
}
int FindNextState(int cur_state, char ch) {
  while (go[cur_state][ch - 'a'] == -1) {
    cur_state = f[cur_state];
  }
  return go[cur_state][ch - 'a'];
}
vector<int> Search(vector<string> &pat, string &txt) {
  vector<int> result(txt.size(), 0);
  BuildMatchingMachine(pat);
  int cur_state = 0;
  for (int i = 0; i < (int)txt.size(); ++i) {
    cur_state = FindNextState(cur_state, txt[i]);
    result[i] = out[cur_state];
  }
  go.clear();
  out.clear();
  f.clear();
  return result;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  int a, b;
  cin >> a >> b;
  int n = a + b;
  long long ans = 0;
  int len = 1;
  while (len <= n) {
    int num = n / len;
    int r = n / num;
    int a_min = (a + num) / (num + 1);
    int a_max = a / num;
    int b_min = (b + num) / (num + 1);
    int b_max = b / num;
    if (a_min <= a_max && b_min <= b_max) {
      ans += min(a_max + b_max, r) - max(len, a_min + b_min) + 1;
    }
    len = r + 1;
  }
  cout << ans;
  return 0;
}

### Prompt

Please provide a Cpp coded solution to the problem described below:

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;
long long RAND(long long n) { return abs((rand() << 15) + rand()) % n; }
vector<vector<int>> go;
vector<int> out;
vector<int> f;
const int alphabet_size = 26;
void BuildMatchingMachine(vector<string> &arr) {
  int number_of_states = 0;
  for (auto &i : arr) {
    number_of_states += i.size();
  }
  go.resize(number_of_states + 1, vector<int>(alphabet_size, -1));
  out.resize(number_of_states + 1, 0);
  f.resize(number_of_states + 1, -1);
  int node = 1;
  for (int i = 0; i < arr.size(); ++i) {
    int current_node = 0;
    for (int j = 0; j < arr[i].size(); ++j) {
      if (go[current_node][arr[i][j] - 'a'] == -1)
        go[current_node][arr[i][j] - 'a'] = node++;
      current_node = go[current_node][arr[i][j] - 'a'];
    }
    out[current_node]++;
  }
  f[0] = 0;
  queue<int> Init_nodes;
  for (int c = 0; c < alphabet_size; ++c) {
    if (go[0][c] == -1) {
      go[0][c] = 0;
    }
    if (go[0][c] != 0) {
      Init_nodes.push(go[0][c]);
    }
    f[go[0][c]] = 0;
  }
  while (!Init_nodes.empty()) {
    int cur_node = Init_nodes.front();
    Init_nodes.pop();
    for (int c = 0; c < 26; ++c) {
      if (go[cur_node][c] != -1) {
        int failure = f[cur_node];
        while (go[failure][c] == -1) {
          failure = f[failure];
        }
        failure = go[failure][c];
        f[go[cur_node][c]] = failure;
        out[go[cur_node][c]] += out[failure];
        Init_nodes.push(go[cur_node][c]);
      }
    }
  }
}
int FindNextState(int cur_state, char ch) {
  while (go[cur_state][ch - 'a'] == -1) {
    cur_state = f[cur_state];
  }
  return go[cur_state][ch - 'a'];
}
vector<int> Search(vector<string> &pat, string &txt) {
  vector<int> result(txt.size(), 0);
  BuildMatchingMachine(pat);
  int cur_state = 0;
  for (int i = 0; i < (int)txt.size(); ++i) {
    cur_state = FindNextState(cur_state, txt[i]);
    result[i] = out[cur_state];
  }
  go.clear();
  out.clear();
  f.clear();
  return result;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  int a, b;
  cin >> a >> b;
  int n = a + b;
  long long ans = 0;
  int len = 1;
  while (len <= n) {
    int num = n / len;
    int r = n / num;
    int a_min = (a + num) / (num + 1);
    int a_max = a / num;
    int b_min = (b + num) / (num + 1);
    int b_max = b / num;
    if (a_min <= a_max && b_min <= b_max) {
      ans += min(a_max + b_max, r) - max(len, a_min + b_min) + 1;
    }
    len = r + 1;
  }
  cout << ans;
  return 0;
}

```