#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k, x;
  cin >> n >> k >> x;
  int c[n];
  for (int i = 0; i < n; i++) {
    cin >> c[i];
  }
  vector<pair<int, pair<int, int> > > ra;
  int start = 0;
  for (int i = 0; i < n; i++) {
    if (c[i] != c[i - 1] && i != 0) {
      ra.push_back({c[i - 1], {start, i - 1}});
      start = i;
    }
    if (i == n - 1) {
      if (c[i] != c[i - 1]) {
        ra.push_back({c[n - 1], {n - 1, n - 1}});
      } else {
        ra.push_back({c[n - 1], {start, n - 1}});
      }
    }
  }
  int ans = 0;
  for (int i = 0; i < ra.size(); i++) {
    if (ra[i].first == x) {
      int start = ra[i].second.first;
      int end = ra[i].second.second;
      int val = end - start + 1;
      if (val + 1 >= 3) {
        int maxi = val;
        int j = 0;
        while (start != 0 && end != n - 1) {
          if (c[start - 1] == c[end + 1]) {
            int temp =
                (ra[i - j - 1].second.second - ra[i - j - 1].second.first + 1) +
                (ra[i + j + 1].second.second - ra[i + j + 1].second.first + 1);
            if (temp >= 3) {
              maxi += temp;
              start = (i - j - 1 == 0 ? 0 : ra[i - j - 1].second.first);
              end = (i + j + 1 == n - 1 ? n - 1 : ra[i + j + 1].second.second);
              j++;
            } else {
              break;
            }
          } else {
            break;
          }
        }
        ans = max(maxi, ans);
      } else {
        continue;
      }
    }
  }
  cout << ans;
  return 0;
}
