CF862A Mahmoud and Ehab and the MEX
题目描述
**题意描述**
在一片邪恶之地,邪恶博士绑架了Mahmoud和Ehab,因为他们在邪恶信息学奥林匹克竞赛(Evil Olympiad in Informatics,EOI)中的突出表现。邪恶博士又决定给他们一些问题让他们回答。问题如下:
邪恶博士对集合很感兴趣。他有一个包含n个整数的集合。邪恶博士认为,如果一个集合的Mex值恰好为x,那么这个集合就是邪恶的。定义Mex值为一个集合中没有出现的最小非负整数。举个例子,Mex({0,2,4}) = 1,Mex({1,2,3}) = 0 。
邪恶博士想让他的集合变得邪恶,因此他会执行一些操作。在每个操作中他可能会加入一个非负整数,也可能删去一个数。请问最少需要多少次操作才能让邪恶博士的集合变得邪恶?
输入格式
第一行,包括两个整数n和x,意义如上述。1
输出格式
仅输出一行,表示邪恶博士最少需要执行多少次操作。
说明/提示
For the first test case Dr. Evil should add $ 1 $ and $ 2 $ to the set performing $ 2 $ operations.
For the second test case Dr. Evil should erase $ 0 $ from the set. After that, the set becomes empty, so the MEX of it is $ 0 $ .
In the third test case the set is already evil.