#include <bits/stdc++.h>
using namespace std;
const long long INF = 8e+1000;
int n, k, x, c[1000];
int main() {
  ios_base::sync_with_stdio(false);
  cin >> n >> k >> x;
  for (int i = 0; i < n; i++) cin >> c[i];
  int res = 0;
  for (int i = 0; i < n - 1; i++) {
    if (c[i] == c[i + 1] && c[i] == x) {
      int l = i - 1, r = i + 2;
      while (l >= 0 && r < n) {
        bool mark = false;
        if (c[l] != c[r]) break;
        if (l > 0 && c[l - 1] == c[l]) l--, mark = true;
        if (r < n - 1 && c[r + 1] == c[r]) r++, mark = true;
        if (mark == false) break;
        l--, r++;
      }
      res = max(res, r - l - 1);
    }
  }
  cout << res;
  return 0;
}
