#include <bits/stdc++.h>
using namespace std;
int n, a[500005], c, cnt_[500005];
vector<int> vc[500005];
void Read() {
  scanf("%d%d", &n, &c);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
  }
}
void Solve() {
  int ans = 0, cnt = 0;
  for (int i = 1; i <= n; i++) {
    if (a[i] == c) {
      cnt++;
    } else {
      cnt_[a[i]] = max(cnt_[a[i]], cnt) + 1;
    }
    ans = max(ans, cnt_[a[i]] - cnt);
  }
  printf("%d", cnt + ans);
}
int main() {
  Read();
  Solve();
  return 0;
}
