#include <bits/stdc++.h>
using namespace std;
int n, k, x;
int arr[111];
int RES = 0;
void inzert(int pos) {
  int res = 0;
  int i = pos, j = pos - 1;
  while (i < n && arr[i] == arr[pos]) i++, res++;
  while (j >= 0 && arr[j] == arr[pos]) j--, res++;
  while (1) {
    if (j < 0 || i >= n) break;
    if (j >= 1) {
      int curColor = arr[j];
      if (arr[i] == curColor && arr[j - 1] == curColor) {
        while (i < n && arr[i] == curColor) i++, res++;
        while (j >= 0 && arr[j] == curColor) j--, res++;
        continue;
      }
    }
    if (i < n - 1) {
      int curColor = arr[i];
      if (arr[i + 1] == curColor && arr[j] == curColor) {
        while (i < n && arr[i] == curColor) i++, res++;
        while (j >= 0 && arr[j] == curColor) j--, res++;
        continue;
      }
    }
    break;
  }
  RES = max(res, RES);
}
int main() {
  cin >> n >> k >> x;
  for (int i = 0; i < n; i++) cin >> arr[i];
  for (int i = 1; i < n; i++)
    if (arr[i] == x && arr[i - 1] == x) inzert(i);
  cout << RES << endl;
  return 0;
}
