#include <bits/stdc++.h>
using namespace std;
vector<int> v;
int n, m, k;
int res = 0;
int solve(vector<int> a) {
  int x, r = 0;
  while (true) {
    int i;
    for (i = 0; i < a.size(); i++) {
      int j;
      x = 1;
      for (j = i + 1; j < a.size(); j++)
        if (a[i] == a[j])
          x++;
        else
          break;
      if (x >= 3) {
        a.erase(a.begin() + i, a.begin() + j);
        r += x;
        break;
      }
    }
    if (i == a.size()) break;
  }
  return r;
}
int main() {
  cin >> n >> k >> m;
  v.resize(n);
  for (int i = 0; i < n; i++) cin >> v[i];
  for (int i = 0; i < n - 1; i++) {
    if (v[i] == v[i + 1] && v[i] == m) {
      vector<int> a = v;
      a.insert(a.begin() + i, m);
      res = max(solve(a) - 1, res);
    }
  }
  cout << res << endl;
}
