#include <bits/stdc++.h>
using namespace std;
int a[110];
int main() {
  int i, j, k, n, m, x;
  scanf("%d%d%d", &n, &m, &x);
  for (i = 1; i <= n; i++) scanf("%d", &a[i]);
  k = 0;
  int ans = 0;
  for (i = 1; i <= n; i++) {
    k++;
    if (i == n || a[i] != a[i + 1]) {
      if (a[i] == x && k == 2) {
        int now = 2, l, r;
        l = i - 2;
        r = i + 1;
        while (r <= n && l > 0 && a[r] == a[l]) {
          int pr = r, pl = l;
          while (r + 1 <= n && a[r + 1] == a[r]) r++;
          while (l - 1 > 0 && a[l - 1] == a[l]) l--;
          if (r - pr + pl - l + 2 >= 3) {
            now += r - pr + pl - l + 2;
          } else
            break;
          r++;
          l--;
        }
        if (now > ans) {
          ans = now;
        }
      }
      k = 0;
    }
  }
  printf("%d\n", ans);
}
