#include <bits/stdc++.h>
using namespace std;
int main() {
  vector<int> balls, temp;
  int best = 0, n, i, k, p, h, t;
  cin >> n >> p >> p;
  balls.reserve(n);
  for (i = 0; i < n; i++) {
    cin >> balls[i];
  }
  for (i = 0; i <= n; i++) {
    temp.resize(n);
    for (k = 0; k < n; k++) {
      temp[k] = balls[k];
    }
    temp.insert(temp.begin() + i, p);
    for (k = 0; k < n; k++) {
      t = 0;
      while (t < temp.size()) {
        h = t;
        while (t < temp.size() && temp[h] == temp[t]) t++;
        if (t - h < 3) continue;
        temp.erase(temp.begin() + h, temp.begin() + t);
        break;
      }
    }
    if (temp.size() == n + 1) continue;
    if (n - (temp.size()) > best) best = n - (temp.size());
  }
  cout << best << endl;
  return 0;
}
