#include <bits/stdc++.h>
struct debugger {
  template <typename T>
  debugger operator,(const T& v) {
    std::cout << v << " ";
    return (*this);
  }
} dbg;
using namespace std;
int main() {
  std::ios_base::sync_with_stdio(false);
  int n, k, x;
  cin >> n >> k >> x;
  vector<std::pair<int, int> > arr;
  for (int i = (1); i <= (n); ++i) {
    int t;
    cin >> t;
    if (((int)((arr).size())) != 0 && arr.back().first == t) {
      arr.back().second += 1;
    } else {
      arr.push_back(make_pair(t, 1));
    }
  }
  int ans = (x == arr[0].first && arr[0].second >= 2) ? arr[0].second : 0;
  for (int i = (1); i < (((int)((arr).size()))); ++i) {
    int b = i - 1, f = i + 1;
    int tans = 0;
    if (x == arr[i].first && arr[i].second >= 2) {
      tans += arr[i].second;
      while (b >= 0 && f < n) {
        if (arr[b].first == arr[f].first &&
            arr[b].second + arr[f].second >= 3) {
          tans += arr[b].second + arr[f].second;
          b--;
          f++;
        } else
          break;
      }
    }
    ans = max(ans, tans);
  }
  cout << ans << "\n";
}
