#include <bits/stdc++.h>
using namespace std;
vector<int> b;
int n;
int dfs(int id, int x) {
  vector<int> a = b;
  a.insert(a.begin() + id, x);
  a.push_back(200);
  int p = 1000, ans = 0;
  if ((id > 0 && id > 1 && a[id - 1] == x && a[id - 2] == x) ||
      (id + 2 < n + 1 && a[id + 1] == x && a[id + 2] == x) ||
      (id > 0 && a[id - 1] == x && a[id + 1] == x))
    ans -= 1;
  while (p--) {
    if (a.size() <= 2) break;
    int last = 0;
    int f = 0;
    for (int i = 1; i < a.size(); i += 1) {
      if (a[i] != a[i - 1]) {
        if (i - last >= 3) {
          a.erase(a.begin() + last, a.begin() + i);
          ans += (i - last);
          f = 1;
          break;
        }
        last = i;
      }
    }
    if (f == 0) break;
  }
  return ans;
}
int main() {
  int k, x;
  cin >> n >> k >> x;
  for (int i = 1; i <= n; i += 1) {
    int xx;
    cin >> xx;
    b.push_back(xx);
  }
  int ans = 0;
  for (int i = 0; i < n; i += 1) {
    int xxx = dfs(i, x);
    ans = max(ans, xxx);
  }
  cout << ans;
  return 0;
}
