Preparando MOJI
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'.
The first line contains two integers $$$a$$$ and $$$b$$$ ($$$1 \le a, b \le 10^9$$$) — the number of letters 'A' and 'B', respectively.
Print the number of different periods over all possible strings with $$$a$$$ letters 'A' and $$$b$$$ letters 'B'.
2 4
4
5 3
5
All the possible periods for the first example:
All the possible periods for the second example:
Note that these are not the only possible strings for the given periods.