#include <bits/stdc++.h>
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast,no-stack-protector,fast-math,unroll-loops")
using namespace std;
const int MAXN = 5e5 + 7, inf = 1e9 + 7, mod = 1e9 + 7, C = 1e4 + 7;
int pr[MAXN], suf[MAXN], a[MAXN], opt[MAXN], last[MAXN];
int n, c;
signed main() {
  cin >> n >> c;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    pr[i] = (a[i] == c) + pr[i - 1];
  }
  for (int i = n; i > 0; i--) {
    suf[i] = suf[i + 1] + (a[i] == c);
  }
  for (int i = 1; i <= n; i++) {
    opt[i] = pr[i - 1] + 1;
    int cur = last[a[i]];
    if (cur) opt[i] = max(opt[i], opt[cur] + 1);
    last[a[i]] = i;
  }
  int ans = 0;
  for (int i = 1; i <= n; i++) ans = max(ans, opt[i] + suf[i + 1]);
  cout << ans << "\n";
}
