#include <bits/stdc++.h>
using namespace std;
const int N = 600031;
int n, C, ar[N], pref[N], suf[N];
int last_entry[N], best_pref[N];
int ans;
int main() {
  ios_base::sync_with_stdio(0);
  cin >> n >> C;
  for (int i = 1; i <= n; i++) {
    cin >> ar[i];
    pref[i] = pref[i - 1];
    if (ar[i] == C) pref[i]++;
  }
  for (int i = n; i >= 1; --i) {
    suf[i] = suf[i + 1];
    if (ar[i] == C) suf[i]++;
  }
  for (int i = 1; i <= n; i++) {
    best_pref[i] = pref[i - 1] + 1;
    int le = last_entry[ar[i]];
    if (le > 0) best_pref[i] = max(best_pref[i], best_pref[le] + 1);
    last_entry[ar[i]] = i;
  }
  for (int i = 1; i <= n; i++) {
    ans = max(ans, best_pref[i] + suf[i + 1]);
  }
  cout << ans << endl;
  return 0;
}
