codeforces#P1202F. You Are Given Some Letters...
You Are Given Some Letters...
Description
You are given uppercase Latin letters 'A' and letters 'B'.
The period of the string is the smallest such positive integer that (-indexed) for each . Note that this implies that won't always divide .
For example, the period of string "ABAABAA" is , the period of "AAAA" is , and the period of "AABBB" is .
Find the number of different periods over all possible strings with letters 'A' and letters 'B'.
The first line contains two integers and () — the number of letters 'A' and 'B', respectively.
Print the number of different periods over all possible strings with letters 'A' and letters 'B'.
Input
The first line contains two integers and () — the number of letters 'A' and 'B', respectively.
Output
Print the number of different periods over all possible strings with letters 'A' and letters 'B'.
Samples
Note
All the possible periods for the first example:
- "BBABBA"
- "BBAABB"
- "BBBAAB"
- "AABBBB"
All the possible periods for the second example:
- "BAABAABA"
- "BAABABAA"
- "BABAAABA"
- "BAABAAAB"
- "AAAAABBB"
Note that these are not the only possible strings for the given periods.