#include <bits/stdc++.h>
using namespace std;
long long M[500005];
long long A[500005];
int main() {
  long long n, c, s = 0, r = 0;
  cin >> n >> c;
  for (long long i = 0; i < n; i++) {
    cin >> M[i];
    if (M[i] == c)
      s++;
    else
      A[M[i]] = max(A[M[i]], s) + 1;
    r = max(r, A[M[i]] - s);
  }
  cout << r + s;
}
