#1547. 邪恶的MEX

邪恶的MEX

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<=n<=100,1<=x<=100.

第二行,包括n个不同的非负整数,且每个数均不超过100,表示一开始集合中的元素。

输出格式:

仅输出一行,表示邪恶博士最少需要执行多少次操作。

题目描述

Dr. Evil kidnapped Mahmoud and Ehab in the evil land because of their performance in the Evil Olympiad in Informatics (EOI). He decided to give them some problems to let them go.

Dr. Evil is interested in sets, He has a set of n n integers. Dr. Evil calls a set of integers evil if the MEX of it is exactly x x . the MEX of a set of integers is the minimum non-negative integer that doesn't exist in it. For example, the MEX of the set 0,2,4 {0,2,4} is 1 1 and the MEX of the set 1,2,3 {1,2,3} is 0 0 .

Dr. Evil is going to make his set evil. To do this he can perform some operations. During each operation he can add some non-negative integer to his set or erase some element from it. What is the minimal number of operations Dr. Evil has to perform to make his set evil?

输入格式

The first line contains two integers n n and x x ( 1<=n<=100 1<=n<=100 , 0<=x<=100 0<=x<=100 ) — the size of the set Dr. Evil owns, and the desired MEX.

The second line contains n n distinct non-negative integers not exceeding 100 100 that represent the set.

输出格式

The only line should contain one integer — the minimal number of operations Dr. Evil should perform.

样例 #1

样例输入 #1

5 3
0 4 5 6 7

样例输出 #1

2

样例 #2

样例输入 #2

1 0
0

样例输出 #2

1

样例 #3

样例输入 #3

5 0
1 2 3 4 5

样例输出 #3

0

提示

For the first test case Dr. Evil should add 1 1 and 2 2 to the set performing 2 2 operations.

For the second test case Dr. Evil should erase 0 0 from the set. After that, the set becomes empty, so the MEX of it is 0 0 .

In the third test case the set is already evil.