#include <bits/stdc++.h>
using namespace std;
int n, k;
int x;
int a[103];
int rec = 0;
int b[103][103];
int st[103];
int stt[103];
int head;
int main() {
  scanf("%d %d %d", &n, &k, &x);
  int i, j;
  for (i = 0; i < n; i++) scanf("%d", &a[i]);
  for (i = 0; i < n; i++) {
    for (j = 0; j < n; j++) {
      if (j < i)
        b[i][j] = a[j];
      else if (i == j) {
        b[i][j] = x;
        b[i][j + 1] = a[j];
      } else
        b[i][j + 1] = a[j];
    }
  }
  for (i = 0; i < n; i++) {
    head = 0;
    int kill = 0;
    for (j = 0; j < n + 1; j++) {
      if (head > 1) {
        if (b[i][j] == st[head - 1] && b[i][j] == st[head - 2]) {
          head--;
          while (head > -1 && st[head] == b[i][j]) {
            if (stt[head] == i) kill = 1;
            head--;
          }
          head++;
          int tem = j;
          while (j < n + 1 && b[i][j] == b[i][tem]) {
            if (i == j) kill = 1;
            j++;
          }
          j--;
        } else {
          stt[head] = j;
          st[head++] = b[i][j];
        }
      } else {
        stt[head] = j;
        st[head++] = b[i][j];
      }
    }
    rec = max(rec, n + 1 - head - kill);
  }
  printf("%d\n", rec);
  return 0;
}
