#include <bits/stdc++.h>
int count_pop(int balls[], int i, int size) {
  int pops = 2;
  int l = i - 2;
  int r = i + 1;
  while (l >= 0 && r < size && balls[l] == balls[r]) {
    int aux_pops = 2;
    bool popped = false;
    if (l - 1 >= 0 && balls[l - 1] == balls[l]) {
      aux_pops++;
      popped = true;
      l--;
    }
    if (r + 1 < size && balls[r + 1] == balls[r]) {
      aux_pops++;
      popped = true;
      r++;
    }
    if (!popped) {
      break;
    } else {
      pops += aux_pops;
      l--;
      r++;
    }
  }
  return pops;
}
int main() {
  int n, k, x;
  scanf("%d", &n);
  scanf("%d", &k);
  scanf("%d", &x);
  int balls[n];
  for (int i = 0; i < n; i++) {
    scanf("%d", &balls[i]);
  }
  int max = 0;
  int count = 0;
  for (int i = 0; i < n; i++) {
    if (balls[i] == x) {
      count++;
    } else {
      count = 0;
    }
    if (count == 2) {
      int pops = count_pop(balls, i, n);
      if (pops > max) {
        max = pops;
      }
    }
  }
  printf("%d", max);
}
