#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9 + 7;
const long double PI = 3.141592653589793238462643383279502884197;
priority_queue<int, vector<int>, greater<int> > pq;
vector<int> v;
int num[500001];
int main() {
  int n, k;
  scanf("%d %d", &n, &k);
  int mav = 0, t, cnt = 0;
  for (int i = 0; i < n; i++) {
    scanf("%d", &t);
    if (t == k)
      cnt++;
    else
      num[t] = max(num[t], cnt) + 1;
    mav = max(mav, num[t] - cnt);
  }
  printf("%d", cnt + mav);
}
