#include <bits/stdc++.h>
using namespace std;
const double eps = 1e-9;
const int inf = 2000000000;
const long long infLL = 9000000000000000000;
inline bool checkBit(long long n, int i) { return n & (1LL << i); }
inline long long setBit(long long n, int i) { return n | (1LL << i); }
inline long long resetBit(long long n, int i) { return n & (~(1LL << i)); }
inline bool EQ(double a, double b) { return fabs(a - b) < 1e-9; }
inline bool isLeapYear(long long year) {
  return (year % 400 == 0) || (year % 4 == 0 && year % 100 != 0);
}
inline void normal(long long &a) {
  a %= 1000000007;
  (a < 0) && (a += 1000000007);
}
inline long long modMul(long long a, long long b) {
  a %= 1000000007, b %= 1000000007;
  normal(a), normal(b);
  return (a * b) % 1000000007;
}
inline long long modAdd(long long a, long long b) {
  a %= 1000000007, b %= 1000000007;
  normal(a), normal(b);
  return (a + b) % 1000000007;
}
inline long long modSub(long long a, long long b) {
  a %= 1000000007, b %= 1000000007;
  normal(a), normal(b);
  a -= b;
  normal(a);
  return a;
}
inline long long modPow(long long b, long long p) {
  long long r = 1;
  while (p) {
    if (p & 1) r = modMul(r, b);
    b = modMul(b, b);
    p >>= 1;
  }
  return r;
}
inline long long modInverse(long long a) {
  normal(a);
  return modPow(a, 1000000007 - 2);
}
inline long long modDiv(long long a, long long b) {
  return modMul(a, modInverse(b));
}
int dx[] = {0, 0, +1, -1};
int dy[] = {+1, -1, 0, 0};
int n, c, a[500005], lc[500005], rc[500005];
vector<int> vt[500005];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  cin >> n >> c;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    vt[a[i]].push_back(i);
  }
  a[0] = a[n + 1] - 1;
  for (int i = 1; i <= n; i++) {
    lc[i] = lc[i - 1];
    if (a[i] == c) lc[i]++;
  }
  for (int i = n; i >= 1; i--) {
    rc[i] = rc[i + 1];
    if (a[i] == c) rc[i]++;
  }
  int ans = lc[n];
  for (int i = 1; i < 500005; i++) {
    if (vt[i].size() == 0 || i == c) continue;
    ;
    int mx = -1e9;
    ans = max(lc[n] + 1, ans);
    for (int j = vt[i].size() - 1; j >= 0; j--) {
      if (j != vt[i].size() - 1) {
        int tpp = j - lc[vt[i][j]];
        ans = max(ans, mx - tpp);
      }
      int tmp = j + 1 + rc[vt[i][j]];
      mx = max(mx, tmp);
      ;
    };
  }
  cout << ans << '\n';
  return 0;
}

### Prompt

Develop a solution in CPP 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>
using namespace std;
const double eps = 1e-9;
const int inf = 2000000000;
const long long infLL = 9000000000000000000;
inline bool checkBit(long long n, int i) { return n & (1LL << i); }
inline long long setBit(long long n, int i) { return n | (1LL << i); }
inline long long resetBit(long long n, int i) { return n & (~(1LL << i)); }
inline bool EQ(double a, double b) { return fabs(a - b) < 1e-9; }
inline bool isLeapYear(long long year) {
  return (year % 400 == 0) || (year % 4 == 0 && year % 100 != 0);
}
inline void normal(long long &a) {
  a %= 1000000007;
  (a < 0) && (a += 1000000007);
}
inline long long modMul(long long a, long long b) {
  a %= 1000000007, b %= 1000000007;
  normal(a), normal(b);
  return (a * b) % 1000000007;
}
inline long long modAdd(long long a, long long b) {
  a %= 1000000007, b %= 1000000007;
  normal(a), normal(b);
  return (a + b) % 1000000007;
}
inline long long modSub(long long a, long long b) {
  a %= 1000000007, b %= 1000000007;
  normal(a), normal(b);
  a -= b;
  normal(a);
  return a;
}
inline long long modPow(long long b, long long p) {
  long long r = 1;
  while (p) {
    if (p & 1) r = modMul(r, b);
    b = modMul(b, b);
    p >>= 1;
  }
  return r;
}
inline long long modInverse(long long a) {
  normal(a);
  return modPow(a, 1000000007 - 2);
}
inline long long modDiv(long long a, long long b) {
  return modMul(a, modInverse(b));
}
int dx[] = {0, 0, +1, -1};
int dy[] = {+1, -1, 0, 0};
int n, c, a[500005], lc[500005], rc[500005];
vector<int> vt[500005];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  cin >> n >> c;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    vt[a[i]].push_back(i);
  }
  a[0] = a[n + 1] - 1;
  for (int i = 1; i <= n; i++) {
    lc[i] = lc[i - 1];
    if (a[i] == c) lc[i]++;
  }
  for (int i = n; i >= 1; i--) {
    rc[i] = rc[i + 1];
    if (a[i] == c) rc[i]++;
  }
  int ans = lc[n];
  for (int i = 1; i < 500005; i++) {
    if (vt[i].size() == 0 || i == c) continue;
    ;
    int mx = -1e9;
    ans = max(lc[n] + 1, ans);
    for (int j = vt[i].size() - 1; j >= 0; j--) {
      if (j != vt[i].size() - 1) {
        int tpp = j - lc[vt[i][j]];
        ans = max(ans, mx - tpp);
      }
      int tmp = j + 1 + rc[vt[i][j]];
      mx = max(mx, tmp);
      ;
    };
  }
  cout << ans << '\n';
  return 0;
}

```