#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, K, X;
  int color[110];
  int i, j, ans, kiri, kanan, temp, skrg, byk;
  cin >> N >> K >> X;
  for (i = 1; i <= N; i++) cin >> color[i];
  ans = 0;
  for (i = 1; i <= N; i++) {
    if (color[i] == X) {
      temp = 0;
      kiri = i;
      kanan = i + 1;
      byk = 1;
      while (true) {
        skrg = color[kiri];
        while (kiri >= 1 && color[kiri] == skrg) {
          byk++;
          kiri--;
        }
        while (kanan <= N && color[kanan] == skrg) {
          byk++;
          kanan++;
        }
        if (byk >= 3) {
          temp += byk;
          byk = 0;
          if (kiri == 0 || kanan == N + 1) break;
        } else
          break;
      }
      if (temp > ans) ans = temp;
    }
  }
  if (ans > 0) ans -= 1;
  cout << ans << endl;
  return 0;
}
