#include <bits/stdc++.h>
using namespace std;
const int MAXN = 500010;
int x[MAXN], sum[MAXN];
int lo[MAXN], p[MAXN], cur[MAXN];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, c;
  cin >> n >> c;
  int add = 0;
  for (int i = 1; i <= 500000; ++i) lo[i] = n;
  for (int i = 1; i <= n; ++i) {
    int v;
    cin >> v;
    x[i] = v;
    sum[i] = sum[i - 1];
    if (v == c) {
      ++sum[i];
    } else {
      ++cur[v];
      cur[v] -= sum[i] - sum[p[v]];
      p[v] = i;
      lo[v] = min(lo[v], cur[v]);
      add = max(add, cur[v] - lo[v] + 1);
    }
  }
  cout << sum[n] + add << '\n';
  return 0;
}
