#include <bits/stdc++.h>
using namespace std;
const int size = 1 << 18;
char buff[size];
int lp = 0, up = 0;
char read_char() {
  if (lp == up) {
    up = fread(buff, sizeof(char), size, stdin);
    if (up == 0) return 0;
    lp = 0;
  }
  return buff[lp++];
}
int read_int() {
  char c;
  do {
    c = read_char();
  } while (c < '0' || c > '9');
  int val = 0;
  for (; c >= '0' && c <= '9'; c = read_char())
    val = (val << 3) + (val << 1) + c - '0';
  return val;
}
int result(vector<int> temp, vector<int> ch, int index, int x, int n) {
  int i, j, k;
  int count = 0;
  if (index == 0) return 0;
  i = index;
  vector<int> arr = temp;
  arr.erase(arr.begin() + index);
  ch.erase(ch.begin() + index);
  while (i > 0 && i < n) {
    if (arr[i] == arr[i - 1] && ch[i] + ch[i - 1] > 2) {
      count += ch[i - 1] + ch[i];
      arr.erase(arr.begin() + i - 1);
      arr.erase(arr.begin() + i - 1);
      ch.erase(ch.begin() + i - 1);
      ch.erase(ch.begin() + i - 1);
      i--;
    } else
      break;
  }
  return count;
}
int main() {
  int i, j, k, n, m, x;
  scanf("%d", &n);
  scanf("%d", &k);
  scanf("%d", &x);
  vector<int> ch(n), arr, value;
  for (i = 0; i < n; i++) scanf("%d", &ch[i]);
  int count = 1;
  for (i = 1; i < n; i++) {
    if (ch[i] == ch[i - 1])
      count++;
    else {
      arr.push_back(ch[i - 1]);
      value.push_back(count);
      count = 1;
    }
  }
  arr.push_back(ch[i - 1]);
  value.push_back(count);
  int flag = 0;
  int val = 0;
  for (i = 0; i < arr.size(); i++) {
    if (arr[i] == x && value[i] > 1) {
      count = value[i];
      count += result(arr, value, i, x, arr.size());
      val = max(count, val);
    }
  }
  printf("%d\n", val);
  return 0;
}
