#include <bits/stdc++.h>
#pragma warning(disable : 4996)
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("-ffloat-store")
using namespace std;
clock_t time_p = clock();
void aryanc403() {
  time_p = clock() - time_p;
  cerr << "Time Taken : " << (float)(time_p) / CLOCKS_PER_SEC << "\n";
}
class CMP {
 public:
  bool operator()(long long int a, long long int b) { return !(a <= b); }
};
void add(map<long long int, long long int> &m, long long int x,
         long long int cnt = 1) {
  map<long long int, long long int>::iterator jt;
  jt = m.find(x);
  if (jt == m.end())
    m.insert(make_pair(x, cnt));
  else
    jt->second += cnt;
}
void del(map<long long int, long long int> &m, long long int x,
         long long int cnt = 1) {
  map<long long int, long long int>::iterator jt;
  jt = m.find(x);
  if (jt->second <= cnt)
    m.erase(jt);
  else
    jt->second -= cnt;
}
bool cmp(const pair<long long int, long long int> &a,
         const pair<long long int, long long int> &b) {
  return a.first < b.first || (a.first == b.first && a.second < b.second);
}
const long long int INF = 0xFFFFFFFFFFFFFFFL;
const long long int mod = 1000000007L;
long long int T, n, i, j, k, in, cnt, l, r, c;
long long int m;
string s;
vector<long long int> a;
vector<long long int> itr[500005];
vector<long long int>::iterator it;
long long int dp1[500005], dp2[500005];
int main(void) {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  {
    cin >> n >> c;
    a.clear();
    a.reserve(n);
    cnt = 0;
    for (i = 0; i < (n); ++i) {
      dp1[i] = cnt;
      cin >> in;
      a.push_back(in);
      itr[in].push_back(i);
      cnt += (in == c);
    }
    cnt = 0;
    for (i = (n - 1); i >= (0); --i) {
      dp2[i] = cnt;
      cnt += (a[i] == c);
    }
    long long int ans = (long long int)itr[c].size();
    for (k = (1); k <= (500000); ++k) {
      if (k == c || itr[k].empty()) continue;
      i = j = 0;
      n = (long long int)itr[k].size();
      while (j < n) {
        while (i < j && j - i + 1 <= dp1[itr[k][j]] - dp1[itr[k][i]]) i++;
        ans = max(ans, dp1[itr[k][i]] + dp2[itr[k][j]] + j - i + 1);
        j++;
      }
    }
    cout << ans << "\n";
  }
  aryanc403();
  return 0;
}

### Prompt

Please provide a cpp coded solution to the problem described below:

You are given array a of length n. You can choose one segment [l, r] (1 ≤ l ≤ r ≤ n) and integer value k (positive, negative or even zero) and change a_l, a_{l + 1}, ..., a_r by k each (i.e. a_i := a_i + k for each l ≤ i ≤ r).

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

Input

The first line contains two integers n and c (1 ≤ n ≤ 5 ⋅ 10^5, 1 ≤ c ≤ 5 ⋅ 10^5) — the length of array and the value c to obtain.

The second line contains n integers a_1, a_2, ..., a_n (1 ≤ a_i ≤ 5 ⋅ 10^5) — array a.

Output

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

Examples

Input


6 9
9 9 9 9 9 9


Output


6


Input


3 2
6 2 6


Output


2

Note

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

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

### Response

```cpp
#include <bits/stdc++.h>
#pragma warning(disable : 4996)
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("-ffloat-store")
using namespace std;
clock_t time_p = clock();
void aryanc403() {
  time_p = clock() - time_p;
  cerr << "Time Taken : " << (float)(time_p) / CLOCKS_PER_SEC << "\n";
}
class CMP {
 public:
  bool operator()(long long int a, long long int b) { return !(a <= b); }
};
void add(map<long long int, long long int> &m, long long int x,
         long long int cnt = 1) {
  map<long long int, long long int>::iterator jt;
  jt = m.find(x);
  if (jt == m.end())
    m.insert(make_pair(x, cnt));
  else
    jt->second += cnt;
}
void del(map<long long int, long long int> &m, long long int x,
         long long int cnt = 1) {
  map<long long int, long long int>::iterator jt;
  jt = m.find(x);
  if (jt->second <= cnt)
    m.erase(jt);
  else
    jt->second -= cnt;
}
bool cmp(const pair<long long int, long long int> &a,
         const pair<long long int, long long int> &b) {
  return a.first < b.first || (a.first == b.first && a.second < b.second);
}
const long long int INF = 0xFFFFFFFFFFFFFFFL;
const long long int mod = 1000000007L;
long long int T, n, i, j, k, in, cnt, l, r, c;
long long int m;
string s;
vector<long long int> a;
vector<long long int> itr[500005];
vector<long long int>::iterator it;
long long int dp1[500005], dp2[500005];
int main(void) {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  {
    cin >> n >> c;
    a.clear();
    a.reserve(n);
    cnt = 0;
    for (i = 0; i < (n); ++i) {
      dp1[i] = cnt;
      cin >> in;
      a.push_back(in);
      itr[in].push_back(i);
      cnt += (in == c);
    }
    cnt = 0;
    for (i = (n - 1); i >= (0); --i) {
      dp2[i] = cnt;
      cnt += (a[i] == c);
    }
    long long int ans = (long long int)itr[c].size();
    for (k = (1); k <= (500000); ++k) {
      if (k == c || itr[k].empty()) continue;
      i = j = 0;
      n = (long long int)itr[k].size();
      while (j < n) {
        while (i < j && j - i + 1 <= dp1[itr[k][j]] - dp1[itr[k][i]]) i++;
        ans = max(ans, dp1[itr[k][i]] + dp2[itr[k][j]] + j - i + 1);
        j++;
      }
    }
    cout << ans << "\n";
  }
  aryanc403();
  return 0;
}

```