#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, K, X;
  cin >> N >> K >> X;
  vector<int> Balls[100];
  for (int i = 0; i < N; i++) {
    int color;
    cin >> color;
    Balls[0].push_back(color);
  }
  for (int i = 1; i < 100; i++) {
    Balls[i] = Balls[0];
  }
  int result = 0;
  for (int i = 0; i < N; i++) {
    Balls[i].insert(Balls[i].begin() + i, X);
    for (int j = 0; j < (int)Balls[i].size() - 2; j++) {
      if (Balls[i][j] == Balls[i][j + 1] && Balls[i][j] == Balls[i][j + 2]) {
        int color = Balls[i][j];
        while (j != (int)Balls[i].size() && Balls[i][j] == color) {
          Balls[i].erase(Balls[i].begin() + j);
        }
        j = -1;
      }
    }
    result = max(result, N - (int)Balls[i].size());
  }
  cout << result;
}
