#include <bits/stdc++.h>
using namespace std;
int howmany(string s, int st, char type) {
  int R = st, L = st;
  while (R < (int)s.size() && s[R] == type) ++R;
  while (L >= 0 && s[L] == type) --L;
  L++;
  R--;
  if (R - L + 1 >= 3) {
    if (R - L + 1 == (int)s.size()) return 0;
    char newtyp = 254;
    string ns = s.substr(0, L);
    int newpos;
    if (ns.size() > 0) {
      newtyp = ns[(int)ns.size() - 1];
      newpos = (int)ns.size() - 1;
    }
    string right = s.substr(min((int)s.size(), R + 1));
    if (newtyp == (char)254) {
      newtyp = right[0];
      newpos = 0;
    }
    ns += right;
    return howmany(ns, newpos, newtyp);
  } else
    return s.size();
}
int main() {
  int n, k, x;
  cin >> n >> k >> x;
  string s = "";
  int d;
  for (int i = 0; i < (int)(n); ++i) {
    cin >> d;
    s += (char)('a' + (d - 1));
  }
  char typ = (char)('a' + (x - 1));
  int mi = 10000;
  for (int p = 1; p < (n); ++p) {
    if (s[p - 1] != typ || s[p] != typ) continue;
    string ns = s.substr(0, p);
    ns += typ;
    ns += s.substr(p);
    int hm = howmany(ns, p, typ);
    mi = min(mi, hm);
  }
  int ans = s.size() - mi;
  if (mi == 10000) ans = 0;
  cout << ans << endl;
}
