#include <bits/stdc++.h>
using namespace std;
const int MAXN = 110;
int n, k, x;
vector<int> boje;
int rjesi(vector<int> niz, int d) {
  bool gotovo = true;
  if (niz.size() < 1) return n - niz.size();
  for (int i = 0; i < niz.size(); i++) {
    int koliko = 0;
    for (int j = i; j < niz.size(); j++) {
      if (niz[j] == niz[i])
        koliko++;
      else
        break;
    }
    if (koliko >= 3) {
      gotovo = false;
      for (int j = 0; j < koliko; j++) niz.erase(niz.begin() + i);
    }
  }
  if (niz.size() < 1) return n - niz.size();
  if (gotovo)
    return n - niz.size();
  else
    return rjesi(niz, 2);
}
int main() {
  int pos = -1;
  int rjesenje = 0;
  scanf("%d %d %d", &n, &k, &x);
  for (int i = 0; i < n; i++) {
    int c;
    scanf("%d", &c);
    boje.push_back(c);
  }
  for (int i = 0; i < n; i++) {
    vector<int> novi = boje;
    novi.insert(novi.begin() + i, x);
    int p = rjesi(novi, 1);
    if (p > rjesenje) {
      rjesenje = p;
      pos = i + 1;
    }
  }
  printf("%d", rjesenje);
  return 0;
}
