#include <bits/stdc++.h>
using namespace std;
long long sm(long long l, long long r, vector<long long> &pref) {
  if (l == 0) {
    return pref[r];
  }
  return pref[r] - pref[l - 1];
}
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  long long n, c;
  cin >> n >> c;
  vector<long long> arr(n);
  for (auto &x : arr) {
    cin >> x;
  }
  vector<long long> pref(n);
  const long long MAXa = (long long)1e6;
  vector<vector<long long>> kek(MAXa);
  for (long long i = 0; i < n; i++) {
    if (arr[i] == c) {
      pref[i] = 1;
    } else {
      kek[arr[i]].push_back(i);
    }
  }
  for (long long i = 1; i < n; i++) {
    pref[i] += pref[i - 1];
  }
  long long ans = 0;
  if (n > pref.back()) {
    ans = 1;
  }
  for (long long i = 1; i < MAXa; i++) {
    if (kek[i].empty()) {
      continue;
    }
    long long pr = kek[i][0];
    long long now = 1;
    for (auto j : kek[i]) {
      if (j == pr) {
        continue;
      }
      now -= sm(pr, j, pref);
      if (now < 0) {
        now = 0;
      }
      now++;
      ans = max(ans, now);
      pr = j;
    }
  }
  cout << pref.back() + ans << '\n';
}
