#include <bits/stdc++.h>
int ball[128], n, ans;
void merge(int l, int r, int c) {
  ans++;
  for (; l >= 0 && ball[l] == c; l--) ans++;
  for (; r < n && ball[r] == c; r++) ans++;
  if (l == 0 && r == n) return;
  if (l == 0 && r + 2 < n && ball[r] == ball[r + 1] && ball[r] == ball[r + 2])
    merge(r, r + 2, ball[r]);
  else if (r == n && l > 1 && ball[l] == ball[l - 1] && ball[l] == ball[l - 2])
    merge(l - 2, l, ball[l]);
  else if (l > 0 && ball[l] == ball[r] && ball[l - 1] == ball[r])
    merge(l - 1, r, ball[l]);
  else if (r < n - 1 && ball[l] == ball[r] && ball[l] == ball[r + 1])
    merge(l, r + 1, ball[l]);
  return;
}
int main(void) {
  int k, i, max;
  scanf("%d%*d%d", &n, &k);
  for (i = 0; i < n; i++) scanf("%d", &ball[i]);
  max = 0;
  for (i = 0; i < n; i++)
    if (ball[i] == k && ball[i + 1] == k) {
      ans = -1;
      merge(i, i + 1, k);
      if (ans > max) max = ans;
    }
  printf("%d\n", max);
  return 0;
}
