#include <bits/stdc++.h>
using namespace std;
inline int read() {
  char ch = getchar();
  int x = 0, f = 1;
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return x * f;
}
int n, k, x, ans = 0;
int a[110];
int main() {
  n = read(), k = read(), x = read();
  for (int i = 1; i <= n; i++) a[i] = read();
  for (int i = 0; i <= n; i++) {
    int l = i, r = i + 1, prel, prer, cnt = 1, temp = x;
    while (1) {
      prel = l, prer = r;
      while (l && a[l] == temp) {
        l--;
        cnt++;
      }
      while (r <= n && a[r] == temp) {
        r++;
        cnt++;
      }
      if (cnt <= 2) {
        l = prel, r = prer;
        break;
      } else
        temp = a[l], cnt = 0;
    }
    ans = max(ans, r - l - 1);
  }
  printf("%d", ans);
  return 0;
}
