#include <bits/stdc++.h>
using namespace std;
priority_queue<int> h[500005];
int n, c, dem[500005], a[500005], num[500005], d[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];
  for (int i = (1); i <= (n); ++i) {
    d[a[i]]++;
    num[i] = d[a[i]];
    dem[i] = dem[i - 1];
    if (a[i] == c) dem[i]++;
  }
  int ans = 0, tmp;
  for (int i = (1); i <= (n); ++i) {
    h[a[i]].push(dem[i - 1] - num[i] + 1);
    tmp = num[i] + h[a[i]].top() + dem[n] - dem[i];
    ans = max(ans, tmp);
  }
  cout << ans;
  return 0;
}
