#include <bits/stdc++.h>
using namespace std;
const int maxn = 110;
int n, k, x, a[maxn], cnt, cur, d[maxn], ans;
vector<pair<int, int> > v;
int main() {
  cin >> n >> k >> x >> a[0];
  cur = a[0], cnt = 1;
  for (int i = 1; i < n; i++) {
    cin >> a[i];
    if (a[i] == cur)
      cnt++;
    else {
      v.push_back(pair<int, int>(cur, cnt));
      cur = a[i], cnt = 1;
    }
  }
  v.push_back(pair<int, int>(cur, cnt));
  for (int i = 0; i < v.size(); i++) {
    int u = v[i].first;
    if (u == x && v[i].second > 1) {
      int sum = 0;
      sum += v[i].second;
      int j = i - 1, p = i + 1;
      while (j >= 0 && p < v.size() && v[j].first == v[p].first &&
             v[j].second + v[p].second >= 3) {
        sum += v[j].second + v[p].second;
        j--, p++;
      }
      ans = max(ans, sum);
    }
  }
  cout << ans << endl;
  return 0;
}
