#include <bits/stdc++.h>
using namespace std;
void insert(vector<int> &v, const int x_pos, const vector<int> &from,
            const int color) {
  int i;
  for (i = 1; i <= x_pos; i++) {
    v[i] = from[i];
  }
  v[i] = color;
  for (; i < from.size(); i++) {
    v[i + 1] = from[i];
  }
}
void print(const vector<int> &v) {
  for (int i = 1; i < v.size(); i++) cout << v[i] << " ";
  cout << endl;
}
void copy(vector<int> &to, const vector<int> &from, int pos, int cnt) {
  if (from.size() == cnt) {
    to.resize(0);
    return;
  }
  to.resize(from.size() - cnt);
  int i;
  for (i = 1; i < pos; i++) {
    to[i] = from[i];
  }
  for (; i + cnt < from.size(); i++) {
    to[i] = from[i + cnt];
  }
}
int count(vector<int> &v) {
  int i = 1;
  vector<int> cp;
  int cnt = 0;
  bool change = 1;
  if (v.size() < 3) return 0;
  for (i = 1; i < v.size() - 2; i++) {
    if (v[i] == v[i + 1] && v[i + 1] == v[i + 2]) {
      if (i + 3 < v.size()) {
        if (v[i + 3] == v[i + 2]) {
          copy(cp, v, i, 4);
          cnt += 4 + count(cp);
        } else {
          copy(cp, v, i, 3);
          cnt += 3 + count(cp);
        }
      } else {
        copy(cp, v, i, 3);
        cnt += 3 + count(cp);
      }
      break;
    }
  }
  return cnt;
}
void solve() {
  int n, k, x;
  cin >> n >> k >> x;
  vector<int> c(n + 1, 0);
  vector<int> compose(n + 1);
  for (int i = 1; i <= n; i++) {
    cin >> c[i];
  }
  int ans = -1, cnt;
  for (int i = 0; i < n + 1; i++) {
    compose.clear();
    compose.resize(n + 2);
    insert(compose, i, c, x);
    ans = max(ans, count(compose) - 1);
  }
  cout << max(ans, 0) << endl;
}
int main() {
  int t = 1;
  while (t--) solve();
}
