#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n, k, first;
  cin >> n >> k >> first;
  vector<pair<int, int>> v;
  int prev = -1;
  for (int i = 0; i < n; i++) {
    int ci;
    cin >> ci;
    if (ci == prev)
      v.back().second++;
    else
      v.push_back({ci, 1});
    prev = ci;
  }
  int mx = 0;
  for (int i = 0; i < ((int)v.size()); i++) {
    int cur = 0;
    if (v[i] == pair<int, int>{first, 2}) {
      cur += 2;
      int l = i - 1, r = i + 1;
      while (l >= 0 && r < ((int)v.size())) {
        if (v[l].first != v[r].first || v[l].second + v[r].second < 3) break;
        cur += v[l].second + v[r].second;
        l--, r++;
      }
    }
    mx = max(mx, cur);
  }
  cout << mx;
  return 0;
}
