#include <bits/stdc++.h>
using namespace std;
using LL = int64_t;
using pii = pair<int, int>;
const int INF = 0x3fffffff;
const LL LINF = 0x3fffffffffffffff;
const double EPS = 1e-9;
const double PI = 2 * asin(1);
int g_n, g_m, g_k;
vector<int> vi_in;
vector<pii> vpii;
void pretreat() {}
bool input() {
  cin >> g_n >> g_m >> g_k;
  if (cin.eof()) return false;
  vi_in.clear(), vpii.clear();
  for (int i = 0, t; i < g_n; ++i) {
    scanf(" %d", &t);
    vi_in.push_back(t);
  }
  return true;
}
void solve() {
  vi_in.push_back(1000);
  for (int i = 0, k = -1; i <= g_n; ++i) {
    if (i == 0 || vi_in[i] != vi_in[i - 1]) {
      if (k != -1) vpii.emplace_back(vi_in[i - 1], k);
      k = 1;
    } else
      ++k;
  }
  vector<int> vi_t;
  for (int i = 0; i < vpii.size(); ++i)
    if (vpii[i].first == g_k) vi_t.push_back(i);
  int ans = 0;
  for (int k = 0; k < vi_t.size(); ++k) {
    vector<pii> vp(vpii.begin(), vpii.end());
    ++vp[vi_t[k]].second;
    bool f = true;
    int sum = 0;
    while (f) {
      f = false;
      vector<pii> vpp;
      vp.emplace_back(1000, 0);
      for (int i = 0, cnt = -1; i < vp.size(); ++i) {
        if (i == 0 || vp[i].first != vp[i - 1].first) {
          if (cnt != -1) vpp.emplace_back(vp[i - 1].first, cnt);
          cnt = vp[i].second;
        } else
          cnt += vp[i].second;
      }
      vp = vpp;
      for (auto it = vp.begin(); it != vp.end(); ++it) {
        if (it->second > 2) {
          sum += it->second;
          vp.erase(it);
          f = true;
          break;
        }
      }
    }
    ans = max(ans, sum);
  }
  if (ans == 0) ans = 1;
  cout << ans - 1 << endl;
}
int main() {
  pretreat();
  while (input()) {
    solve();
  }
  return 0;
}
