#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k, x;
  cin >> n >> k >> x;
  vector<int> a(n);
  for (int i = 0; i < n; ++i) cin >> a[i];
  vector<int> color;
  vector<int> count;
  int curColor = a[0];
  int curCount = 1;
  for (int i = 1; i < n; ++i) {
    if (a[i] == curColor)
      ++curCount;
    else {
      color.push_back(curColor);
      count.push_back(curCount);
      curColor = a[i];
      curCount = 1;
    }
  }
  color.push_back(curColor);
  count.push_back(curCount);
  int result = 0;
  int len = color.size();
  for (int i = 0; i < len; ++i) {
    if (color[i] != x || count[i] < 2) continue;
    int cur = count[i];
    for (int k = 1; i - k >= 0 && i + k < len; ++k) {
      if (color[i - k] != color[i + k] || (count[i - k] + count[i + k]) < 3)
        break;
      cur += count[i - k] + count[i + k];
    }
    if (cur > result) result = cur;
  }
  cout << result << endl;
  return 0;
}
