Information

Time Limit: Java: 2000 ms / Others: 2000 ms

Memory Limit: Java: 32768 KB / Others: 32768 KB

Description

It is a war between Country Alpha and Country Beta. Country Alpha gets following information about Country Beta:

Country Beta has n (2

Now, Country Alpha wants to demolish one city of Country Beta. Thus, Alpha will make the number of cities in the largest group as small as possible.

Input

Ther are multiple test cases (about 200 cases). There is a blank line between each case.

The first line of each case contains two positive integers, n and m (0

Output

Output the least number of cities in a group, which is the largest group after Country Alpha's attack. By the way, a group must consist of at least two cities, that is, one city is not able to be considered as a group. If there is no group, output 0.

Sample Input

2 2
0 1
1 0

Sample Output

0

Hint

None

Source

ZOJ Monthly, July 2012

提交代码