#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
int clr[N];
int cnt[N];
int a[N];
int n, k, x;
int group = 0;
void change() {
  cnt[group] = 1;
  clr[group] = a[0];
  for (int i = 1; i < n; i++) {
    if (a[i] == a[i - 1])
      cnt[group]++;
    else {
      group++;
      cnt[group] = 1;
      clr[group] = a[i];
    }
  }
}
int main() {
  while (cin >> n >> k >> x) {
    group = 0;
    for (int i = 0; i < n; i++) cin >> a[i];
    change();
    int l, r;
    int ans = 0;
    for (int i = 0; i <= group; i++) {
      int res = 0;
      if (clr[i] == x && cnt[i] >= 2) {
        l = r = i;
        res += cnt[i];
        while (l > 0 && r < group) {
          l--;
          r++;
          if (clr[l] != clr[r]) break;
          if (cnt[l] + cnt[r] < 3) break;
          res += (cnt[l] + cnt[r]);
        }
      }
      ans = max(res, ans);
    }
    cout << ans << endl;
  }
}
