#include <bits/stdc++.h>
using namespace std;
int32_t main(void) {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long i, j;
  long long n, c;
  cin >> n >> c;
  long long a[n + 1];
  for (i = 1; i < n + 1; i++) cin >> a[i];
  long long cum[n + 1];
  cum[1] = (a[1] == c);
  for (i = 2; i <= n; i++) cum[i] = cum[i - 1] + (a[i] == c);
  unordered_map<long long, long long> prev;
  prev.reserve(n + 10);
  long long dp[n + 1];
  memset(dp, 0, sizeof(dp));
  for (i = 1; i <= n; i++) {
    if (a[i] == c) continue;
    if (prev.count(a[i])) {
      dp[i] = max(dp[prev[a[i]]] + 1 - (cum[i] - cum[prev[a[i]]]), cum[n] + 1);
      prev[a[i]] = i;
    } else {
      dp[i] = cum[n] + 1;
      prev[a[i]] = i;
    }
  }
  cout << max(*max_element(dp, dp + n + 1), cum[n]) << "\n";
  return 0;
}
