4.5 Paper game 📃
(RankList for this Question)
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?

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

Log In to solve the Question