PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN

#QHD0000029. Tăng số lần xuất hiện (Increasing Frequency)

HỌC THEO LỘ TRÌNH

Bài tập thuộc lộ trình

1 lộ trình

Tăng số lần xuất hiện (Increasing Frequency)

Increasing Frequency

Source: Codeforces

Version: Phuoc Hung OJ Extended

Problem Statement

Given an array a1,a2,…,ana_1,a_2,\ldots,a_n and a target value cc, maximize the number of array elements equal to cc.

You may perform at most one operation: choose a consecutive segment [l,r][l,r], select an integer kk, and add kk to every element in that segment. Elements outside the segment remain unchanged. Choosing k=0k=0 leaves the array unchanged.

Output the largest possible frequency of cc after the operation.

Input

The first line contains nn and cc.

The second line contains the array of nn integers.

Output

Print the maximum achievable number of occurrences of cc.

Subtasks

  • Subtask 1 (20 points): 1≤n≤301\le n\le 30; 1≤c≤5⋅1051\le c\le 5\cdot10^5; 1≤ai≤5⋅1051\le a_i\le 5\cdot10^5.
  • Subtask 2 (30 points): 1≤n≤20001\le n\le 2000; 1≤c≤5⋅1051\le c\le 5\cdot10^5; 1≤ai≤5⋅1051\le a_i\le 5\cdot10^5.
  • Subtask 3 (50 points): 1≤n≤5⋅1051\le n\le 5\cdot10^5; 1≤c≤5⋅1051\le c\le 5\cdot10^5; 1≤ai≤5⋅1051\le a_i\le 5\cdot10^5.

Examples

Input

3 2
6 2 6

Output

2

Explanation

Initially (6,2,6)(6,2,6) has one occurrence of 22. Adding −4-4 to the first element produces (2,2,6)(2,2,6), with two occurrences. Turning both 66 values into 22 would also change the middle 22, so three occurrences are impossible.