4.5 Paper game ðŸ“ƒ

Score: 25pts

Time Limit: 3.00 sec

Imagine you have a large rectangular piece of paper with dimensions aÃ—b, and you're embarking on a creative project. Your mission is to transform this paper into squares, but there's a twist: you can only use a pair of scissors to make cuts.

The challenge is to achieve this transformation using as few cuts as possible, ensuring that all sides of the resulting pieces remain whole numbers. Can you figure out the minimum number of cuts required to turn this paper into squares, thus unlocking the full potential of your artistic endeavor?

The challenge is to achieve this transformation using as few cuts as possible, ensuring that all sides of the resulting pieces remain whole numbers. Can you figure out the minimum number of cuts required to turn this paper into squares, thus unlocking the full potential of your artistic endeavor?

Constraints

1â‰¤a,bâ‰¤500

Input Format

The only input line has two integers a and b

Output Format

Print the minimum number of moves.

Example 1

Input:

3 5

Output:

3

Explanation:

This testcase is self explanatory

3 5

Output:

3

Explanation:

This testcase is self explanatory