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?


Input Format
The only input line has two integers a and b

Output Format
Print the minimum number of moves.

Example 1
3 5


This testcase is self explanatory

Log In to solve the Question