#include <bits/stdc++.h>
using namespace std;
long long power(long long base, long long pow, long long mo) {
  long long res = 1;
  while (pow) {
    if (pow % 2 != 0) res = (res * base) % mo;
    base = (base * base) % mo;
    pow /= 2;
  }
  return res;
}
std::string str = "All Good Till Here";
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long tt, i, j, count = 0, c = 0, c1 = 0, count3 = 0, count2 = 0, l, r, n,
                      k, x;
  tt = 1;
  bool t = false;
  while (tt--) {
    cin >> n >> k >> x;
    long long arr[n];
    for (long long c1 = 0; c1 < n; c1++) cin >> arr[c1];
    ;
    for (long long i = 0; i < n - 1; i++) {
      if (arr[i] == arr[i + 1] && arr[i] == x && i + 1 != n - 1 && i != 0) {
        l = i - 1;
        r = i + 2;
        c1 = 2;
        if (l >= 0 && r < n) {
          c = 0;
          while (l >= 0 && r < n) {
            if (arr[l] == arr[r]) {
              c = 2;
              if (l - 1 >= 0) {
                if (arr[l - 1] == arr[l]) {
                  c++;
                  l--;
                }
              }
              if (r + 1 < n) {
                if (arr[r + 1] == arr[r]) {
                  c++;
                  r++;
                }
              }
              if (c == 2) break;
              c1 += c;
              r++;
              l--;
            } else
              break;
          }
          count = max(count, c1);
        }
      }
    }
    cout << count << "\n";
  }
  return 0;
}
