Sphere Online Judge

SPOJ Problem Set (classical)

1417. University Employees

Problem code: EMP

On some island each inhabitant is either a knight who only tells the truth, or a liar who always lies. Also, on the island there exists a university of technology where some of the inhabitants work. All of the university employees will always tell you the following two things, no matter which employee you ask:

1. There are fewer than N employees who work more than me.


2. At least M employees of the university have a larger salary than me.


It is also known that no two employees of the university have an identical salary, and no two work equally. Write a program which will compute how many persons are employed by this university.

Input

The only input line contains two integers N and M, with one space between them [N, M <= 1000000000].

Output

The output must contain only one integer - the total number of employees of this university, or 0 if there is no way to find the number of employees.

Example

Input:
1 1

Output:
2

Author: Filimonenkov D.O.


Added by:Roman Sol
Date:2006-04-24
Time limit:1s
Source limit:50000B
Languages:All except: CLOJ ERL F# JS PERL 6 TECS
Resource:ZCon 2007

hide comments
2010-08-29 12:02:30 Andrey Fursenko
It seems test of this problem covered only cases where N == M (0 0, 1 1, 2 2, 3 3...)
I think so because my wrong solution was accepted, and then my right code was accepted as well.

Last edit: 2010-08-29 12:04:04
2010-08-25 11:52:36 vicky
i started thinking too much and fooled myself :P

Last edit: 2010-08-26 10:52:11
2010-07-21 23:02:28 Avatar
a simple practice problem!!
2010-07-13 20:04:31 Chandra sekar
Easy one! :)
2010-07-05 15:37:25 Tornike Mandzulashvili
have a man more salary,if he works more?
SPOJ System © 2010 Sphere Research Labs. All Rights Reserved.