#include <bits/stdc++.h>
using namespace std;
vector<pair<int, int> > v;
int destroy() {
  int flag = 0;
  for (int i = 0; i < v.size(); ++i) {
    if (v[i].second >= 3) {
      v.erase(v.begin() + i);
      flag = 1;
      --i;
    }
  }
  return flag;
}
int close() {
  int flag = 0;
  int n = v.size();
  for (int i = 0; i < n - 1; ++i) {
    if (v[i].first == v[i + 1].first) {
      v[i].second += v[i + 1].second;
      v.erase(v.begin() + i + 1);
      flag = 1;
      --i;
    }
    n = v.size();
  }
  return flag;
}
int main() {
  int n, k, x;
  cin >> n >> k >> x;
  int ct = 0, curp = -100;
  for (int i = 0; i < n; ++i) {
    int p;
    cin >> p;
    if (p != curp) {
      if (curp != -100) v.push_back(pair<int, int>(curp, ct));
      curp = p;
      ct = 0;
    }
    ++ct;
  }
  if (curp != -100) v.push_back(pair<int, int>(curp, ct));
  vector<pair<int, int> > cpy = v;
  int ans = 0;
  for (int i = 0; i < cpy.size(); ++i) {
    if (cpy[i].first == x) {
      v[i].second++;
      while (destroy() && close())
        ;
    }
    int balls = 0;
    for (int j = 0; j < v.size(); ++j) balls += v[j].second;
    if (n - balls > ans) ans = n - balls;
    v = cpy;
  }
  cout << ans << endl;
}
