#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int get_score(int idx, vector<int> a, int color) {
  int score = 0;
  a.erase(a.begin() + idx);
  a.erase(a.begin() + idx);
  for (int i = 0; i < a.size(); i++) {
    int j = i + 1;
    while (j < a.size() && a[i] == a[j]) {
      j++;
    }
    if (j - i >= 3) {
      score += j - i;
      a.erase(a.begin() + i, a.begin() + j);
      i = 0;
    }
  }
  score += 2;
  return score;
}
int main() {
  int n, k, x;
  cin >> n >> k >> x;
  vector<int> a(n);
  for (int i = 0; i < n; i++) cin >> a[i];
  int ans = 0;
  vector<int> tmp = a;
  int res = 0;
  int where = -1;
  for (int i = 0; i + 1 < a.size(); i++) {
    if (a[i] == x && a[i] == a[i + 1]) {
      res = max(res, get_score(i, a, x));
    }
  }
  cout << res;
  return 0;
}
