#include <bits/stdc++.h>
using namespace std;
int n, k, f[500001], ans, cnt, x;
int main() {
  cin >> n >> k;
  for (int i = 0; i < n; i++) {
    cin >> x;
    if (x == k)
      cnt++;
    else
      f[x] = max(f[x], cnt) + 1;
    ans = max(ans, f[x] - cnt);
  }
  cout << ans + cnt;
  return 0;
}
