#P1082E. Increasing Frequency

    ID: 4508 Type: RemoteJudge 2000ms 256MiB Tried: 0 Accepted: 0 Difficulty: (None) Uploaded By: Tags>binary searchdpgreedy*2000

Increasing Frequency

No submission language available for this problem.

Description

You are given array aa of length nn. You can choose one segment [l,r][l, r] (1lrn1 \le l \le r \le n) and integer value kk (positive, negative or even zero) and change al,al+1,,ara_l, a_{l + 1}, \dots, a_r by kk each (i.e. ai:=ai+ka_i := a_i + k for each lirl \le i \le r).

What is the maximum possible number of elements with value cc that can be obtained after one such operation?

The first line contains two integers nn and cc (1n51051 \le n \le 5 \cdot 10^5, 1c51051 \le c \le 5 \cdot 10^5) — the length of array and the value cc to obtain.

The second line contains nn integers a1,a2,,ana_1, a_2, \dots, a_n (1ai51051 \le a_i \le 5 \cdot 10^5) — array aa.

Print one integer — the maximum possible number of elements with value cc which can be obtained after performing operation described above.

Input

The first line contains two integers nn and cc (1n51051 \le n \le 5 \cdot 10^5, 1c51051 \le c \le 5 \cdot 10^5) — the length of array and the value cc to obtain.

The second line contains nn integers a1,a2,,ana_1, a_2, \dots, a_n (1ai51051 \le a_i \le 5 \cdot 10^5) — array aa.

Output

Print one integer — the maximum possible number of elements with value cc which can be obtained after performing operation described above.

Samples

Sample Input 1

6 9
9 9 9 9 9 9

Sample Output 1

6

Sample Input 2

3 2
6 2 6

Sample Output 2

2

Note

In the first example we can choose any segment and k=0k = 0. The array will stay same.

In the second example we can choose segment [1,3][1, 3] and k=4k = -4. The array will become [2,2,2][2, -2, 2].