#include <bits/stdc++.h>
using namespace std;
const double EPS = 1e-9, PI = 2 * acos(0.0);
const int maxn = 10000000 + 10, MOD = 1000 * 1000 * 1000 + 7,
          INF = 1000 * 1000 * 1000;
int n, k, x, t;
int a[120][2];
int func(int f, int e) {
  if (f >= 0 && e < n && a[f][0] == a[e][0] && a[f][1] + a[e][1] > 2)
    return a[f][1] + a[e][1] + func(f - 1, e + 1);
  return 0;
}
int main() {
  cin >> n >> k >> x;
  cin >> a[0][0];
  a[0][1] = 1;
  int p = 0, m = 0;
  for (int i = 1; i < n; i++) {
    cin >> t;
    if (t == a[p][0])
      a[p][1]++;
    else {
      p++;
      a[p][0] = t;
      a[p][1] = 1;
    }
  }
  n = p + 1;
  for (int i = 0; i < n; i++) {
    if (a[i][1] > 1 && a[i][0] == x) {
      m = max(m, func(i - 1, i + 1) + a[i][1]);
    }
  }
  cout << m << endl;
  return 0;
}
