#include <bits/stdc++.h>
using namespace std;
const int maxn = 5e5 + 10;
const int inf = 1e9;
struct node {
  int s, ind;
} f[maxn];
int sum[maxn];
int cmp(node a, node b) {
  if (a.s == b.s) return a.ind < b.ind;
  return a.s < b.s;
}
int main() {
  int i, n, c, re = 0, value;
  scanf("%d%d", &n, &c);
  for (i = 1; i <= n; i++) {
    scanf("%d", &f[i].s);
    f[i].ind = i;
    sum[i] = sum[i - 1] + (f[i].s == c);
  }
  sort(f + 1, f + n + 1, cmp);
  for (i = 1; i <= n; i++) {
    if (f[i].s == c) continue;
    if (f[i].s != f[i - 1].s) {
      value = 1;
      re = max(re, value);
      continue;
    }
    value -= (sum[f[i].ind - 1] - sum[f[i - 1].ind]);
    if (value < 0) value = 0;
    value++;
    re = max(re, value);
  }
  printf("%d", re + sum[n]);
  return 0;
}
