CF2149C.MEX rose

传统题 时间 2000 ms 内存 256 MiB 4 尝试 1 已通过 1 标签

MEX rose

You are given an array aa of length nn and a number kk, where 0kn0 \le k \le n.

In one operation, you can choose any index ii (1in1 \le i \le n) and set aia_i to any integer value xx from the range [0,n][0,n].

Find the minimum number of such operations required to satisfy the condition: MEX(a)\operatorname{MEX}(a)^{\text{∗}}=k=k

^{\text{∗}}The minimum excluded (MEX) of a set of numbers a1,a2,,ana_1,a_2,\dots,a_n is the smallest non-negative integer xx that does not appear among the aia_i.

Input

Each test consists of several sets of input data.

The first line contains one integer tt (1t1041 \le t \le 10^4) — the number of sets of input data. The description of the sets of input data follows.

The first line of each set of input data contains two integers nn and kk (1n2105,0kn1 \le n \le 2 \cdot 10^5,\,\, 0 \le k \le n) — the length of the array aa and the required MEX(a)\operatorname{MEX}(a).

The second line contains nn integers a1,a2,,ana_1,a_2,\dots,a_n (0ain0 \le a_i \le n) — the elements of the array aa.

It is guaranteed that the sum of the values of nn across all sets of input data does not exceed 21052 \cdot 10^5.

Output

For each set of input data, output one integer — the minimum number of operations required to satisfy the condition MEX(a)=k\operatorname{MEX}(a)=k.

Note

In the first set of input data, the array a=[0]a=[0], so MEX=1\operatorname{MEX}=1. \\ By removing zero (replacing it with any x[1,n]x\in[1,n]), we get MEX=0\operatorname{MEX}=0. \\ Thus, exactly one operation is required.

In the third set of input data, the array contains all the numbers 0,1,2,3,40,1,2,3,4, so MEX(a)=5\operatorname{MEX}(a)=5 from the start.

Since this matches the required kk, no changes are needed and the minimum number of operations is 00.

Samples

5
1 0
0
3 1
0 2 3
5 5
0 1 2 3 4
6 2
0 3 4 2 6 2
7 4
0 1 5 4 4 7 3
1
0
0
2
2

在线编程 IDE

建议全屏模式获得最佳体验