#include <bits/stdc++.h>
using namespace std;
long long int numdigit(long long int n) { return floor(log10(n)) + 1; }
bool isPowerTwo(long long int x) { return x && (!(x & (x - 1))); }
int slv(vector<int> v, int prv_ps, int ps, int n) {
  int ans = 0;
  int ct = 0;
  int i = prv_ps, j = ps;
  if (i >= 0 && j < n) {
    if (v[i] != v[j]) return ans;
  }
  for (i = prv_ps; i >= 0; i--) {
    if (v[prv_ps] == v[i])
      ct++;
    else
      break;
  }
  for (j = ps; j < n; j++) {
    if (v[j] == v[ps])
      ct++;
    else
      break;
  }
  if (ct > 2) {
    ans = ans + ct + slv(v, i, j, n);
  }
  return ans;
}
int main() {
  int t = 1;
  while (t--) {
    int ans = 0;
    int n, k, x;
    cin >> n >> k >> x;
    vector<int> v(n);
    for (int i = 0; i < n; i++) cin >> v[i];
    for (int ps = 1; ps < n; ps++) {
      if (v[ps] == v[ps - 1] && v[ps] == x) {
        ans = max(ans, 2 + slv(v, ps - 2, ps + 1, n));
      }
    }
    cout << ans << "\n";
  }
  return 0;
}
