#include <bits/stdc++.h>
using namespace std;
vector<int> V, tmp;
int main() {
  int i, j;
  int a, b;
  int n, m, k;
  cin >> n >> k >> m;
  for (i = 0; i < n; i++) {
    cin >> a;
    V.push_back(a);
  }
  tmp = V;
  int mx = 0;
  for (i = 1; i < n; i++) {
    tmp = V;
    if (tmp[i] == tmp[i - 1] && tmp[i] == m) {
      int ind = i;
      tmp.erase(tmp.begin() + ind - 1);
      tmp.erase(tmp.begin() + ind - 1);
      bool c = false;
      for (j = 0; j < tmp.size(); j++) {
        c = false;
        if (j + 2 < tmp.size() && tmp[j] == tmp[j + 1] &&
            tmp[j] == tmp[j + 2]) {
          while (tmp[j] == tmp[j + 1] && j + 1 < tmp.size()) {
            tmp.erase(tmp.begin() + j);
            c = true;
          }
          tmp.erase(tmp.begin() + j);
        }
        if (c) j = (-1);
      }
      mx = max(mx, (int)(V.size() - tmp.size()));
    }
  }
  cout << mx << endl;
  return 0;
}
