#include <bits/stdc++.h>
using namespace std;
const int maxn = 500 * 1000 + 20;
int n, c, a[maxn], cCount, ans, cnt[maxn], dp[maxn], dp_help[maxn];
void input() {
  cin >> n >> c;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    if (a[i] == c) cCount++;
  }
}
void output() { cout << ans << endl; }
int main() {
  input();
  for (int i = 0; i < n; i++) {
    cnt[a[i]]++;
    if (a[i] != c) {
      dp_help[a[i]] = min(dp_help[a[i]], cnt[a[i]] - cnt[c] - 1);
      dp[i] = cCount - cnt[c] + cnt[a[i]] - dp_help[a[i]];
    }
  }
  ans = cCount;
  for (int i = 0; i < n; i++) ans = max(ans, dp[i]);
  output();
}
