#include <bits/stdc++.h>
using namespace std;
struct Color {
  int num;
  int color;
};
int n, k, x;
Color c[100 + 16];
int main() {
  scanf("%d %d %d", &n, &k, &x);
  int tmp;
  int len = 1;
  for (int i = 1; i <= n; i++) {
    scanf("%d", &tmp);
    if (c[len - 1].color != tmp) {
      c[len].color = tmp;
      c[len++].num = 1;
    } else {
      c[len - 1].num += 1;
    }
  }
  int max_sum = 0;
  for (int i = 1; i < len; i++) {
    if (c[i].num >= 2 && c[i].color == x) {
      int tmp_sum = c[i].num;
      int l = i - 1, r = i + 1;
      while (l > 0 && r < len && c[l].color == c[r].color &&
             c[l].num + c[r].num > 2) {
        tmp_sum += c[l].num + c[r].num;
        l -= 1, r += 1;
      }
      max_sum = max(max_sum, tmp_sum);
    }
  }
  printf("%d\n", max_sum);
  return 0;
}
