GIRLSNBS - Girls and Boys

There are G girl students and B boy students in a class that is about to graduate. You need to arrange them in a single row for the graduation. To give a better impression of diversity, you want to avoid having too many girls or too many boys seating consecutively. You decided to arrange the students in order to minimize the gender regularity. The gender regularity of an arrangement is the maximum number of students of the same gender (all girls or all boys) that appear consecutively. Given G and B, calculate the minimum gender regularity among all possible arrangements.

Input

Each test case is described using a single line. The line contains two integers G and B representing the number of girls and boys in the class, respectively (0 ≤ G, B ≤ 1000). The end of input is indicated with a line containing the number −1 twice.

Output

For each test case, output a single line with a single integer representing the minimum gender regularity that an arrangement of G girls and B boys can have.

Example

Input: 
10 10
5 1
0 1000
-1 -1
Output:
1
3
1000

Added by:Pablo Ariel Heiber
Date:2010-09-27
Time limit:2s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All except: ASM64 NODEJS OBJC VB.NET
Resource:FCEyN UBA ICPC Selection 2010

hide comments
2015-10-31 15:09:24 Rahul Chaurasia
so easy
input :
256 23
123 12
11 6

output :
11
10
2
2015-10-09 18:36:38
my first problem AC in one go.........
2015-10-02 21:15:07
ac in one go! :)
2015-09-19 11:35:34 Shyam singh
simplest one...AC in one go ... ;P
2015-08-31 13:30:24
easy one...take care of : G=0, B=0;
2015-08-04 14:56:12 Yuvak Patel
AC in first go,easy one!!
2015-06-26 06:32:49
i don't understand the problem ._. if you don't mind, explain please, thanks :D

edit : already understand :D

Last edit: 2015-06-26 06:43:27
2015-05-18 16:40:21 hareesh
AC in first go :)
2015-05-15 17:44:28
so eassyyyy
2015-04-07 08:53:33 kamran siddique
Thanks vikki
© Spoj.com. All Rights Reserved. Spoj uses Sphere Engine™ © by Sphere Research Labs.