#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k, x, mx = 0, sum, dec, inc;
  cin >> n >> k >> x;
  vector<int> v(n);
  for (int i = 0; i < n; i++) cin >> v[i];
  for (int i = 0; i < n - 1; i++) {
    sum = 0;
    if (v[i] == v[i + 1] && v[i] == x) {
      sum = 2;
      int L = i - 1, R = i + 2;
      while (L >= 0 && (R < n) && v[L] == v[R]) {
        dec = L;
        inc = R;
        int cnt = 2;
        while (dec && v[dec - 1] == v[dec]) {
          cnt++;
          dec--;
        }
        while (inc < n - 1 && v[inc + 1] == v[inc]) {
          cnt++;
          inc++;
        }
        if (cnt > 2) {
          sum += cnt;
          L = dec - 1;
          R = inc + 1;
        } else
          break;
      }
      mx = max(mx, sum);
    }
  }
  cout << mx;
  return 0;
}
