#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int t = 1;
  while (t--) {
    long long int n, k, x, i, j;
    cin >> n >> k >> x;
    vector<pair<long long int, long long int>> v;
    for (i = 0; i < n; i++) {
      long long int tm, y = v.size() - 1;
      cin >> tm;
      if (i == 0)
        v.push_back({tm, 1});
      else if (v[y].first == tm)
        v[y].second++;
      else
        v.push_back({tm, 1});
    }
    long long int ans = 0;
    if (v[0].second == 2) ans = 2;
    for (i = 1; i < v.size(); i++) {
      if (v[i].second == 2 && v[i].first == x) {
        long long int l = i, r = v.size() - i - 1, cnt, tans = 2;
        cnt = min(l, r);
        l = i - 1;
        r = i + 1;
        while (cnt != 0) {
          cnt--;
          if (v[l].first == v[r].first && v[l].second + v[r].second >= 3) {
            tans += v[l].second + v[r].second;
            l--;
            r++;
          } else
            break;
        }
        ans = max(ans, tans);
      }
    }
    cout << ans << "\n";
  }
}
