시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 128 MB49431126965.291%

문제

A worm is going to eat chocolate in a form of a rectangle with M rows and N columns.

It starts eating at the upper left corner and eats the entire row to its end. It then turns clockwise and continues to eat the whole column (the last one). Upon reaching its end, the process is repeated, i.e. the worm turns clockwise and eats the entire last row. By repeating this process of eating the chocolate, worm will eat the whole chocolate.

Write a program that will compute the number of turns the worm made until it ate the whole chocolate.

입력

The first and only line of the input contains two integers, M and N, 2 ≤ M,N ≤ 100,. separated by a space character. M is number of rows and N is number of columns. 

출력

The first and only line of output should contain the number of turns a worm needs to make until it eats the whole chocolate.

예제 입력 1

2 3

예제 출력 1

2

예제 입력 2

5 3

예제 출력 2

5

예제 입력 3

4 10

예제 출력 3

6

출처

Olympiad > Croatian Highschool Competitions in Informatics > 2004 > Regional Competition - Seniors 1번

  • 잘못된 데이터를 찾은 사람: joonas