#include <bits/stdc++.h>
using namespace std;
const long long inf = 1e18;
const long long mod = 1e9 + 7;
const long long MOD = 998244353;
long long ans = 0;
void sovle(vector<pair<long long, long long>> pre, long long i) {
  long long l = i - 1, r = i + 1;
  long long res = 2;
  while (l >= 0 && r < pre.size()) {
    long long sum = pre[l].first + pre[r].first;
    if (pre[l].second != pre[r].second || sum < 3) break;
    res += sum;
    l--, r++;
  }
  ans = max(ans, res);
}
void bugaboo_solver() {
  long long n, k, x;
  cin >> n >> k >> x;
  vector<long long> arr(n);
  vector<pair<long long, long long>> pre;
  long long r = 0;
  for (long long i = 0; i < n; i++) {
    cin >> arr[i];
    if (i && arr[i] != arr[i - 1]) {
      pre.push_back({r, arr[i - 1]});
      r = 0;
    }
    r += 1;
  }
  pre.push_back({r, arr[n - 1]});
  for (long long i = 0; i < pre.size(); i++) {
    if (pre[i].first == 2 && pre[i].second == x) {
      sovle(pre, i);
    }
  }
  cout << ans;
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  long long t = 1;
  for (long long i = 1; i <= t; i++) {
    bugaboo_solver();
    cout << '\n';
  }
}
