#include <bits/stdc++.h>
using namespace std;
long long maxa = 0;
int n, k, first;
void check(vector<pair<int, int> > a, int index) {
  a[index].second += 1;
  int deleted = -1;
  stack<pair<int, int> > s;
  for (int i = 0; i < a.size(); i++) {
    if (s.empty())
      s.push(a[i]);
    else {
      if (s.top().first == a[i].first) {
        pair<int, int> t1 = s.top();
        pair<int, int> t2 = a[i];
        s.pop();
        t1.second += t2.second;
        s.push(t1);
      } else {
        s.push(a[i]);
      }
    }
    if (s.top().first == deleted || s.top().second >= 3) {
      deleted = s.top().first;
      s.pop();
    } else {
      deleted = -1;
    }
  }
  int cnt = 0;
  while (!s.empty()) {
    cnt += s.top().second;
    s.pop();
  }
  long long rem = n - cnt;
  maxa = max(maxa, rem);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n >> k >> first;
  vector<pair<int, int> > a;
  int t;
  cin >> t;
  a.push_back({t, 1});
  for (int i = 1; i < n; i++) {
    int temp;
    cin >> temp;
    if (temp == t)
      a[a.size() - 1].second += 1;
    else {
      a.push_back({temp, 1});
      t = temp;
    }
  }
  for (int i = 0; i < a.size(); i++) {
    if (a[i].first == first) {
      if (a[i].second >= 2) check(a, i);
    }
  }
  cout << maxa << "\n";
  return 0;
}
