#include <bits/stdc++.h>
using namespace std;
int arr[109];
int n, k, x, asdaadffsqwe;
struct cont {
  int c, n;
  cont() {}
  cont(int c, int n) : c(c), n(n) {}
};
vector<cont> con;
int main() {
  scanf("%d%d%d", &n, &k, &x);
  memset(arr, 0, sizeof(arr));
  for (int i = 1; i <= n; i++) scanf("%d", &arr[i]);
  int len = 0;
  for (int i = 1; i <= n; i++) {
    len++;
    if (arr[i] != arr[i + 1]) {
      con.push_back(cont(arr[i], len));
      len = 0;
    }
  }
  int ans = 0;
  for (int i = 0; i < con.size(); i++) {
    if (con[i].c != x || con[i].n != 2) continue;
    int tans = 2;
    for (int j = 1;
         i - j >= 0 && i + j < n && con[i - j].n + con[i + j].n >= 3 &&
         con[i - j].c == con[i + j].c;
         j++)
      tans += con[i - j].n + con[i + j].n;
    ans = max(ans, tans);
  }
  printf("%d\n", ans);
  return 0;
}
