#include <bits/stdc++.h>
int c[120], a[120];
int main() {
  int n, k, x, max = 0;
  scanf("%d%d%d", &n, &k, &x);
  for (int i = 1; i <= n; i++) scanf("%d", &c[i]);
  for (int i = 2; i <= n; i++) {
    if (c[i] == x && c[i - 1] == c[i]) {
      for (int j = 1; j <= i - 1; j++) a[j] = c[j];
      a[i] = x;
      for (int j = i + 1; j <= n + 1; j++) a[j] = c[j - 1];
    }
    int resp = 0;
    int k1 = i, k2 = i;
    while (k1 != 0 && k2 != 0) {
      for (int j = k1 - 1; j >= 0; j--) {
        if (a[j] != a[k1]) {
          k1 = j;
          break;
        }
      }
      for (int j = k2 + 1; j <= n + 2; j++) {
        if (a[j] != a[k2]) {
          k2 = j;
          break;
        }
      }
      if (a[k2 - 1] == a[k1 + 1] && k2 - k1 - resp - 1 >= 3)
        resp = k2 - k1 - 1;
      else
        break;
    }
    if (resp > max) max = resp;
  }
  if (max > 0)
    printf("%d\n", max - 1);
  else
    printf("%d\n", max);
  return 0;
}
