#include <bits/stdc++.h>
using namespace std;
int Q[111], F[111];
int main() {
  int n, k, x;
  cin >> n >> k >> x;
  int m = 0;
  for (int i = 1; i <= n; i++) {
    int z;
    cin >> z;
    if (z == Q[m]) {
      F[m]++;
    } else
      Q[++m] = z, F[m]++;
  }
  int max_sum = 0;
  for (int i = 1; i <= m; i++) {
    int sum = 0;
    if (Q[i] == x && F[i] > 1) {
      int a = i - 1, b = i + 1;
      sum = 2;
      while (i >= 1 && b <= m) {
        if (Q[a] != Q[b] || (F[a] + F[b]) < 3) {
          break;
        }
        sum += F[a] + F[b];
        a--;
        b++;
      }
      max_sum = max(max_sum, sum);
    }
  }
  cout << max_sum << endl;
}
