#include <bits/stdc++.h>
using namespace std;
int static fast = []() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  return 0;
}();
int main() {
  int n, k, x;
  cin >> n >> k >> x;
  vector<int> arr(n, 0);
  for (int i = 0; i < n; i++) cin >> arr[i];
  vector<vector<int>> comp;
  int pre = -1, cnt = 0;
  for (int i = 0; i < n; i++) {
    if (arr[i] != pre) {
      if (cnt > 0) comp.push_back({pre, cnt});
      cnt = 1;
    } else {
      cnt += 1;
    }
    pre = arr[i];
  }
  if (cnt > 0) comp.push_back({pre, cnt});
  int ans = 0;
  for (int i = 0; i < comp.size(); i++) {
    if (comp[i][0] == x && comp[i][1] >= 2) {
      int tmp = comp[i][1];
      int l = i - 1, r = i + 1;
      while (l >= 0 && r < comp.size() && comp[l][0] == comp[r][0] &&
             comp[l][1] + comp[r][1] >= 3) {
        tmp += comp[l][1] + comp[r][1];
        l--;
        r++;
      }
      ans = max(ans, tmp);
    }
  }
  cout << ans << "\n";
  return 0;
}
