#include <bits/stdc++.h>
using namespace std;
int b[102];
int f(int a, int n, int x) {
  for (int i = 1; i <= a; i++) b[i - 1] = b[i];
  b[a] = x;
  int i = 0, t = 0, k = 0, start = 0, ans = 0;
  while (i <= n) {
    if (b[i] != k) {
      if (t >= 3) {
        for (int j = i; j <= n; j++) {
          b[start] = b[j];
          start++;
        }
        n = start - 1;
        i = -1;
        ans += t;
      }
      t = 1;
      k = b[i];
      start = i;
    } else
      t++;
    i++;
  }
  if (t >= 3) ans += t;
  ans--;
  return ans;
}
int main() {
  int n, k, x, a[102], ans = 0, temp;
  cin >> n >> k >> x;
  for (int i = 1; i <= n; i++) cin >> a[i];
  for (int i = 0; i <= n; i++) {
    for (int j = 0; j <= n; j++) b[j] = a[j];
    temp = f(i, n, x);
    if (temp > ans) ans = temp;
  }
  cout << ans << endl;
  return 0;
}
