Codeforces celebrates 10 years! We are pleased to announce the crowdfunding-campaign. Congratulate us by the link https://codeforces.com/10years.
×

Virtual contest is a way to take part in past contest, as close as possible to participation on time. It is supported only ICPC mode for virtual contests.
If you've seen these problems, a virtual contest is not for you - solve these problems in the archive.
If you just want to solve some problem from a contest, a virtual contest is not for you - solve this problem in the archive.
Never use someone else's code, read the tutorials or communicate with other person during a virtual contest.

No tag edit access

F. You Are Given Some Letters...

time limit per test

1 secondmemory limit per test

256 megabytesinput

standard inputoutput

standard outputYou 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 \le a, b \le 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.

Codeforces (c) Copyright 2010-2020 Mike Mirzayanov

The only programming contests Web 2.0 platform

Server time: Feb/22/2020 13:31:46 (f2).

Desktop version, switch to mobile version.

Supported by

User lists

Name |
---|