#include <bits/stdc++.h>
using std::cin;
using std::cout;
size_t Simulate(std::vector<int> balls, int X, size_t index) {
  balls.insert(balls.begin() + index, X);
  bool done = false;
  while (!done) {
    done = true;
    size_t i = 0;
    while (i < balls.size()) {
      size_t j = i;
      while (j < balls.size() && balls[i] == balls[j]) {
        ++j;
      }
      if (j - i >= 3) {
        balls.erase(balls.begin() + i, balls.begin() + j);
        done = false;
        break;
      } else {
        i = j;
      }
    }
  }
  return balls.size();
}
int main() {
  std::ios_base::sync_with_stdio(false);
  int N, K, X;
  cin >> N >> K >> X;
  --X;
  std::vector<int> balls(N);
  for (int& value : balls) {
    cin >> value;
    --value;
  }
  size_t min_size = balls.size();
  for (size_t index = 0; index <= balls.size(); ++index) {
    size_t size = Simulate(balls, X, index);
    min_size = std::min(min_size, size);
  }
  cout << balls.size() - min_size << '\n';
  return 0;
}
