ČOKOLADA
문제
Marin's mother bought Marin a chocolate bar with N rows and M columns. Marin knows he cannot be selfish, so he decided to split the chocolate with his friends. He will split the chocolate in such a way that he makes cuts between rows and columns of remaining bars (starting with just one bar). In the end, all the remaining bars must be square shaped, i.e. have the same number of rows and columns. He wants to share the chocolate with only his best friends so he will split it in such a way that there is a minimal number of remaining square shaped bars left. Of course, no chocolate can be wasted.
[이미지 1]
In the pictures above, N is 3 and M is 4. First split ends up with 6 square bars and the second one with 4, which also makes the optimal cut.
Help Marin split his chocolate bar into smallest number of square shaped bars.
입력
In the first and only line read integers N and M (1 ≤ N, M ≤ 1000), the number of rows and columns of the chocolate bar.
출력
In the first and only line output a single integer - the minimal number of remaining square shaped bars.
예제
예제 1
3 4
4
예제 2
4 4
1
예제 3
2 5
4