#include <bits/stdc++.h>
using namespace std;
int N, K, X, N_orig;
int palle[110], copia[110];
int Prova2(int l) {
  int c = 0;
  for (int i = 0; i < N; i++) {
    int j = i, cont = 0;
    while (j < N && palle[j] == palle[i]) {
      j++;
      cont++;
    }
    if (cont >= 3) {
      c += cont;
      for (int k = i; k + cont < N; k++) palle[k] = palle[k + cont];
      N -= cont;
      c += Prova2(0);
    }
  }
  return c;
}
int Prova() {
  int sol = 0;
  for (int i = 0; i < N; i++) {
    if (palle[i] != X) continue;
    int c = 0, j = i;
    while (j < N && palle[j] == X) {
      j++;
      c++;
    }
    if (c >= 2) {
      for (int k = i; k + c < N; k++) palle[k] = palle[k + c];
      N -= c;
      int ris = c + Prova2(0);
      sol = max(sol, ris);
      for (int k = 0; k < N_orig; k++) palle[k] = copia[k];
      N = N_orig;
    }
  }
  return sol;
}
int main() {
  cin >> N >> K >> X;
  N_orig = N;
  for (int i = 0; i < N; i++) {
    cin >> palle[i];
    copia[i] = palle[i];
  }
  cout << Prova() << endl;
  return 0;
}
