#include <bits/stdc++.h>
using namespace std;
int n, k, x;
int c[1001];
int pos[101];
int tot = 0;
int main() {
  cin >> n >> k >> x;
  for (int i = 1; i <= n; i++) {
    scanf("%d", &c[i]);
    if (c[i] == c[i - 1] && c[i] == x) pos[++tot] = i;
  }
  if (!tot) {
    printf("0\n");
    return 0;
  }
  int maxx = 0;
  for (int i = 1; i <= tot; i++) {
    int x = pos[i];
    int ans = 2;
    int l = x - 2, r = x + 1;
    while (l > 0 && r <= n && c[l] == c[r]) {
      if (c[l - 1] == c[l] && c[r + 1] == c[r]) {
        ans += 4;
        l -= 2;
        r += 2;
      } else if (c[l - 1] == c[l]) {
        ans += 3;
        l -= 2;
        r++;
      } else if (c[r + 1] == c[r]) {
        ans += 3;
        l--;
        r += 2;
      } else
        break;
    }
    maxx = max(maxx, ans);
  }
  printf("%d\n", maxx);
  return 0;
}
