#include <bits/stdc++.h>
using namespace std;
int destroy(vector<int> v) {
  int osz = v.size();
  bool k = true;
  while (k) {
    k = false;
    int p = -1;
    int cursz = 0;
    int fp = -1;
    for (int i = 0; i < v.size(); i++) {
      if (v[i] == p) {
        cursz++;
        if (cursz >= 3) {
          fp = i - 2;
          break;
        }
      } else {
        p = v[i];
        cursz = 1;
      }
    }
    if (fp != -1) {
      k = true;
      int ep = fp;
      for (; ep < v.size() && v[ep] == v[fp]; ep++)
        ;
      v.erase(v.begin() + fp, v.begin() + ep);
    }
  }
  return osz - v.size() - 1;
}
int main() {
  int n, k, x;
  cin >> n >> k >> x;
  vector<int> arr;
  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;
    arr.push_back(a);
  }
  int mx = 0;
  for (int i = 0; i <= n; i++) {
    vector<int> a2 = arr;
    a2.insert(a2.begin() + i, x);
    mx = max(mx, destroy(a2));
  }
  cout << mx << endl;
}
