#include <bits/stdc++.h>
using namespace std;
int n, m, k;
int x[105], y[105], s[105];
int a[105];
int f[105][105];
int main() {
  scanf("%d%d%d", &n, &m, &k);
  int tot = 0;
  for (int i = 1, c; i <= n; i++) {
    scanf("%d", &c);
    if (c == x[tot])
      y[tot]++;
    else
      x[++tot] = c, y[tot] = 1;
  }
  for (int i = 1; i <= tot; i++) {
    s[i] = s[i - 1] + y[i];
    if (x[i] == k && y[i] >= 2) f[i][i] = 1;
  }
  for (int l = 3; l <= tot; l += 2)
    for (int i = 1; i + l - 1 <= tot; i++) {
      int j = i + l - 1;
      if (x[i] == x[j] && y[i] + y[j] >= 3 && f[i + 1][j - 1]) f[i][j] = 1;
    }
  int ans = 0;
  for (int i = 1; i <= tot; i++)
    for (int j = i; j <= tot; j++)
      if (f[i][j])
        if (s[j] - s[i - 1] > ans) ans = s[j] - s[i - 1];
  printf("%d\n", ans);
}
