#include <bits/stdc++.h>
using namespace std;
int mod = 1000000007;
int binpow(int a, int b) {
  if (b == 0) return 1;
  long long res = binpow(a, b / 2);
  long long result = (res * res) % mod;
  long long result2 = (result * a) % mod;
  if (b % 2)
    return result2;
  else
    return result;
}
int phi(int n) {
  int result = n;
  for (int i = 2; i * i <= n; i++) {
    if (n % i == 0) {
      while (n % i == 0) n /= i;
      result -= result / i;
    }
  }
  if (n > 1) result -= result / n;
  return result;
}
long long inv(long long i) { return binpow(i % mod, mod - 2); }
vector<bool> isprime;
void sieve(int n) {
  isprime.assign(n + 1, true);
  isprime[0] = isprime[1] = false;
  for (int i = 2; i <= n; i++) {
    if (isprime[i] && (long long)i * i <= n) {
      for (int j = i * i; j <= n; j += i) isprime[j] = false;
    }
  }
}
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
vector<int> facs;
void fac(int n) {
  facs.assign(n + 1, 0);
  facs[0] = 1;
  long long result = 1;
  for (int i = 1; i <= n; i++) {
    result = (result * i) % mod;
    facs[i] = result;
  }
}
bool comp(int &a, int &b) { return (a > b); }
int comb(int n, int k) {
  if (k > n) return 0;
  return ((long long)facs[n] * inv((long long)facs[n - k] * facs[k])) % mod;
}
int perm(int n, int k) {
  if (k > n) return 0;
  return ((long long)facs[n] * inv(facs[n - k])) % mod;
}
void print(pair<int, int> x) { cout << x.first << " " << x.second << '\n'; }
void print(pair<long long, int> x) {
  cout << x.first << " " << x.second << '\n';
}
void print(vector<int> v) {
  for (auto u : v) cout << u << " ";
  cout << '\n';
}
void print(vector<long long> v) {
  for (auto u : v) cout << u << " ";
  cout << '\n';
}
void print(set<int> s) {
  for (auto u : s) cout << u << " ";
  cout << '\n';
}
void print(set<long long> s) {
  for (auto u : s) cout << u << " ";
  cout << '\n';
}
void print(vector<pair<int, int> > v) {
  for (auto u : v) print(u);
}
void print(map<int, int> m) {
  for (auto u : m) print((pair<int, int>)u);
}
void print(map<long long, int> m) {
  for (auto u : m) print((pair<long long, int>)u);
}
map<long long, int> factor(long long n) {
  map<long long, int> factorization;
  while (n % 2 == 0) {
    factorization[2]++;
    n /= 2;
  }
  for (long long d = 3; d * d <= n; d += 2) {
    while (n % d == 0) {
      factorization[d]++;
      n /= d;
    }
  }
  if (n > 1) factorization[n]++;
  return factorization;
}
vector<int> parent, sizee;
void make_set(int n) {
  parent.assign(n + 1, 0);
  sizee.assign(n + 1, 1);
  for (int i = 1; i <= n; i++) parent[i] = i;
}
int find_set(int v) {
  if (v == parent[v]) return v;
  return parent[v] = find_set(parent[v]);
}
void union_sets(int a, int b) {
  a = find_set(a);
  b = find_set(b);
  if (a != b) {
    if (sizee[a] < sizee[b]) swap(a, b);
    parent[b] = a;
    sizee[a] += sizee[b];
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n, c;
  cin >> n >> c;
  vector<int> a(n);
  map<int, vector<int> > hj;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    hj[a[i]].push_back(i);
  }
  vector<int> dp(n, 0);
  if (a[0] == c) dp[0]++;
  for (int i = 1; i < n; i++) {
    dp[i] = dp[i - 1];
    if (a[i] == c) {
      dp[i]++;
    }
  }
  int ans = hj[c].size();
  for (auto u : hj) {
    int rj = u.first;
    if (rj == c) continue;
    vector<int> temp;
    if (u.second[0] != 0) {
      temp.push_back(-dp[u.second[0] - 1]);
    }
    for (int i = 0; i < u.second.size() - 1; i++) {
      temp.push_back(1);
      temp.push_back(-dp[u.second[i + 1] - 1] + dp[u.second[i]]);
    }
    temp.push_back(1);
    if (u.second[u.second.size() - 1] != n - 1)
      temp.push_back(-dp[n - 1] + dp[u.second[u.second.size() - 1]]);
    int maxx = INT_MIN;
    int sum = 0;
    for (int i = 0; i < temp.size(); i++) {
      if (temp[i] > 0) {
        sum += temp[i];
      } else if (temp[i] + sum < 0) {
        sum = 0;
      } else {
        maxx = max(maxx, sum);
        sum += temp[i];
      }
      maxx = max(maxx, sum);
    }
    ans = max(ans, (int)hj[c].size() + maxx);
  }
  cout << ans << '\n';
  return 0;
}

### Prompt

Create a solution in Cpp for the following problem:

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;
int mod = 1000000007;
int binpow(int a, int b) {
  if (b == 0) return 1;
  long long res = binpow(a, b / 2);
  long long result = (res * res) % mod;
  long long result2 = (result * a) % mod;
  if (b % 2)
    return result2;
  else
    return result;
}
int phi(int n) {
  int result = n;
  for (int i = 2; i * i <= n; i++) {
    if (n % i == 0) {
      while (n % i == 0) n /= i;
      result -= result / i;
    }
  }
  if (n > 1) result -= result / n;
  return result;
}
long long inv(long long i) { return binpow(i % mod, mod - 2); }
vector<bool> isprime;
void sieve(int n) {
  isprime.assign(n + 1, true);
  isprime[0] = isprime[1] = false;
  for (int i = 2; i <= n; i++) {
    if (isprime[i] && (long long)i * i <= n) {
      for (int j = i * i; j <= n; j += i) isprime[j] = false;
    }
  }
}
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
vector<int> facs;
void fac(int n) {
  facs.assign(n + 1, 0);
  facs[0] = 1;
  long long result = 1;
  for (int i = 1; i <= n; i++) {
    result = (result * i) % mod;
    facs[i] = result;
  }
}
bool comp(int &a, int &b) { return (a > b); }
int comb(int n, int k) {
  if (k > n) return 0;
  return ((long long)facs[n] * inv((long long)facs[n - k] * facs[k])) % mod;
}
int perm(int n, int k) {
  if (k > n) return 0;
  return ((long long)facs[n] * inv(facs[n - k])) % mod;
}
void print(pair<int, int> x) { cout << x.first << " " << x.second << '\n'; }
void print(pair<long long, int> x) {
  cout << x.first << " " << x.second << '\n';
}
void print(vector<int> v) {
  for (auto u : v) cout << u << " ";
  cout << '\n';
}
void print(vector<long long> v) {
  for (auto u : v) cout << u << " ";
  cout << '\n';
}
void print(set<int> s) {
  for (auto u : s) cout << u << " ";
  cout << '\n';
}
void print(set<long long> s) {
  for (auto u : s) cout << u << " ";
  cout << '\n';
}
void print(vector<pair<int, int> > v) {
  for (auto u : v) print(u);
}
void print(map<int, int> m) {
  for (auto u : m) print((pair<int, int>)u);
}
void print(map<long long, int> m) {
  for (auto u : m) print((pair<long long, int>)u);
}
map<long long, int> factor(long long n) {
  map<long long, int> factorization;
  while (n % 2 == 0) {
    factorization[2]++;
    n /= 2;
  }
  for (long long d = 3; d * d <= n; d += 2) {
    while (n % d == 0) {
      factorization[d]++;
      n /= d;
    }
  }
  if (n > 1) factorization[n]++;
  return factorization;
}
vector<int> parent, sizee;
void make_set(int n) {
  parent.assign(n + 1, 0);
  sizee.assign(n + 1, 1);
  for (int i = 1; i <= n; i++) parent[i] = i;
}
int find_set(int v) {
  if (v == parent[v]) return v;
  return parent[v] = find_set(parent[v]);
}
void union_sets(int a, int b) {
  a = find_set(a);
  b = find_set(b);
  if (a != b) {
    if (sizee[a] < sizee[b]) swap(a, b);
    parent[b] = a;
    sizee[a] += sizee[b];
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n, c;
  cin >> n >> c;
  vector<int> a(n);
  map<int, vector<int> > hj;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    hj[a[i]].push_back(i);
  }
  vector<int> dp(n, 0);
  if (a[0] == c) dp[0]++;
  for (int i = 1; i < n; i++) {
    dp[i] = dp[i - 1];
    if (a[i] == c) {
      dp[i]++;
    }
  }
  int ans = hj[c].size();
  for (auto u : hj) {
    int rj = u.first;
    if (rj == c) continue;
    vector<int> temp;
    if (u.second[0] != 0) {
      temp.push_back(-dp[u.second[0] - 1]);
    }
    for (int i = 0; i < u.second.size() - 1; i++) {
      temp.push_back(1);
      temp.push_back(-dp[u.second[i + 1] - 1] + dp[u.second[i]]);
    }
    temp.push_back(1);
    if (u.second[u.second.size() - 1] != n - 1)
      temp.push_back(-dp[n - 1] + dp[u.second[u.second.size() - 1]]);
    int maxx = INT_MIN;
    int sum = 0;
    for (int i = 0; i < temp.size(); i++) {
      if (temp[i] > 0) {
        sum += temp[i];
      } else if (temp[i] + sum < 0) {
        sum = 0;
      } else {
        maxx = max(maxx, sum);
        sum += temp[i];
      }
      maxx = max(maxx, sum);
    }
    ans = max(ans, (int)hj[c].size() + maxx);
  }
  cout << ans << '\n';
  return 0;
}

```