#include <bits/stdc++.h>
long long min(long long x, long long y) {
  if (x > y) return y;
  return x;
}
long long max(long long x, long long y) {
  if (x > y) return x;
  return y;
}
using namespace std;
int a[123], b[123], t[123];
int n, l, ans = INT_MIN;
void check() {
  int f = 0;
  while (f == 0) {
    int c = 0, i, cnt = 1;
    while (t[c]) c += 1;
    for (i = c + 1; i < l; i++) {
      if (t[i] == 1) continue;
      if (a[i] == a[c])
        cnt += 1;
      else {
        if (cnt >= 3) {
          for (int j = c; j < i; j++) t[j] = 1;
          break;
        }
        cnt = 1;
        c = i;
      }
    }
    if (i == l && cnt >= 3)
      for (int j = c; j < l; j++) t[j] = 1;
    if (i == l) f = 1;
  }
  int cnt = 0;
  for (int i = 0; i < l; i++)
    if (t[i] == 1) cnt += 1;
  cnt--;
  if (cnt > ans) ans = cnt;
}
int main() {
  int n, k, x;
  scanf("%d", &n);
  scanf("%d", &k);
  scanf("%d", &x);
  for (int i = 0; i < n; i++) scanf("%d", &a[i]);
  for (int i = 0; i < n; i++) b[i] = a[i];
  for (int i = 1; i <= n - 1; i++) {
    for (int j = n - 1; j >= i; j--) a[j + 1] = a[j];
    a[i] = x;
    l = n + 1;
    memset(t, 0, sizeof(t));
    check();
    for (int i = 0; i < n; i++) a[i] = b[i];
  }
  if (ans > 0)
    printf("%d", ans);
  else
    printf("0");
  return 0;
}
