#include <bits/stdc++.h>
using namespace std;
struct {
  int c;
  int num;
} ball[110];
int xx[100];
int main() {
  int n, k, x;
  while (cin >> n >> k >> x) {
    int i, j = 0, co, t = 0, sum, m = 0, p, h = 0;
    cin >> ball[j].c;
    ball[j].num = 1;
    if (co == x && h == 0) xx[t++] = j;
    for (i = 1; i < n; i++) {
      cin >> co;
      if (co == ball[j].c) {
        ball[j].num++;
        h = 1;
      } else {
        h = 0;
        j++;
        ball[j].c = co;
        ball[j].num = 1;
      }
      if (co == x && h == 0) xx[t++] = j;
    }
    for (i = 0; i < t; i++) {
      p = xx[i];
      if (ball[p].num >= 2) {
        sum = ball[p].num;
        int u = 1;
        while (ball[p - u].c == ball[p + u].c && p - u >= 0 && p + u <= j) {
          if (ball[p - u].num + ball[p + u].num >= 3) {
            sum += ball[p - u].num + ball[p + u].num;
            u++;
          } else
            break;
        }
      }
      if (m < sum) m = sum;
    }
    cout << m << endl;
  }
}
