#include <bits/stdc++.h>
using namespace std;
int sim(vector<int> s, int p, int x) {
  s.insert(s.begin() + p, x);
  int l = p, r = p;
  int acum = 0;
  int ans = 0;
  for (;;) {
    while (l >= 0 && s[l] == x) l--;
    while (r <= (int)s.size() - 1 && s[r] == x) r++;
    int dis = r - l - 1;
    if (dis - acum >= 3) {
      ans += dis - acum;
      acum += dis - acum;
    } else
      break;
    if (l == -1 || r == (int)s.size()) break;
    if (s[l] == s[r]) x = s[l];
  }
  return ans - 1;
}
int main() {
  int n, k, x;
  cin >> n >> k >> x;
  vector<int> ns(n);
  for (int i = 0; i < n; i++) cin >> ns[i];
  int ans = 0;
  for (int i = 0; i <= n; i++) {
    ans = max(ans, sim(ns, i, x));
  }
  cout << ans << endl;
  return 0;
}
