#include <bits/stdc++.h>
using namespace std;
long long n, k, x, maxx, b[1000000], a[1000000], ans, kol, ii;
int t = 0;
bool ok;
int main() {
  cin >> n >> k >> x;
  for (int i = 0; i < n; i++) cin >> a[i];
  maxx = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < i; j++) b[j] = a[j];
    b[i] = x;
    k = i;
    for (int j = i; j < n; j++) {
      k++;
      b[k] = a[j];
    }
    kol = 0;
    ii = 1;
    ok = false;
    ans = 1;
    while (ii <= k) {
      if (b[ii] == b[ii - 1]) ans++;
      if (b[ii] != b[ii - 1] || ii == k) {
        if (ans > 2) {
          kol += ans;
          if (ii == k && b[ii] == b[ii - 1]) {
            ok = true;
          } else {
            for (int j = ii; j <= k; j++) {
              ok = true;
              b[j - ans] = b[j];
            }
          }
          if (ok) k -= ans;
          ii = 0;
          ok = false;
        }
        ans = 1;
      }
      ii++;
    }
    if (kol > maxx) {
      maxx = kol;
    }
  }
  if (maxx == 0)
    cout << 0 << endl;
  else
    cout << maxx - 1 << endl;
}
