#include <bits/stdc++.h>
#pragma comment(linker, "/stack:256000000")
using namespace std;
int solve(vector<int> a) {
  if (a.empty()) return 0;
  for (int(L) = 0; (L) < ((int)(a).size()); (L)++) {
    int color = a[L];
    int R = L;
    for (; R < (int)(a).size(); R++) {
      if (a[R] != color) {
        break;
      }
    }
    if (R - L >= 3) {
      vector<int> b;
      for (int(i) = 0; (i) < (L); (i)++) b.push_back(a[i]);
      for (int i = R; i < (int)(a).size(); i++) b.push_back(a[i]);
      return R - L + solve(b);
    }
  }
  return 0;
}
int main() {
  int n, x;
  cin >> n >> x >> x;
  vector<int> v(n);
  for (int(i) = 0; (i) < (n); (i)++) cin >> v[i];
  int res = 0;
  for (int(i) = 0; (i) < (n + 1); (i)++) {
    vector<int> a = v;
    a.insert(a.begin() + i, x);
    res = max(res, solve(a));
  }
  cout << max(res - 1, 0) << endl;
  return 0;
}
