#include <bits/stdc++.h>
using namespace std;
int ballsDestroyed(vector<int> a) {
  int destroyed = 0;
  int maxNoOfSame = 0;
  int startPos = 0;
  int endPos = 0;
  int noOfSame = 0;
  while (a.size() > 2) {
    maxNoOfSame = 0;
    noOfSame = 0;
    int index = 0;
    int currentNo = a[index];
    for (int i = 0; i < a.size(); i++) {
      if (currentNo == a[i]) {
        noOfSame++;
      } else {
        currentNo = a[i];
        if (noOfSame > maxNoOfSame) {
          startPos = index;
          endPos = i - 1;
          maxNoOfSame = noOfSame;
        }
        noOfSame = 1;
        index = i;
      }
    }
    if (noOfSame > maxNoOfSame) {
      maxNoOfSame = noOfSame;
      endPos = a.size() - 1;
      startPos = index;
    }
    if (maxNoOfSame <= 2) {
      break;
    } else {
      a.erase(a.begin() + startPos, a.begin() + (endPos + 1));
      destroyed += (endPos - startPos + 1);
    }
  }
  return max(destroyed - 1, 0);
}
void solve() {
  int n;
  int k;
  int x;
  cin >> n >> k >> x;
  vector<int> balls(n);
  for (long long int i = 0; i < n; i++) {
    cin >> balls[i];
  }
  int position = -1;
  int maxLen = INT_MIN;
  int currentLen = 0;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    a = balls;
    a.insert(a.begin() + i, x);
    currentLen = ballsDestroyed(a);
    if (currentLen > maxLen) {
      maxLen = currentLen;
    }
  }
  cout << maxLen << endl;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  solve();
}
