#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k, x;
  cin >> n >> k >> x;
  int a[n + 5];
  int ans = 0;
  for (int i = 0; i < n; i++) cin >> a[i];
  for (int i = 0; i < n - 1; i++) {
    if (a[i] == x && a[i + 1] == x) {
      int cnt = 2;
      int pA = i - 1, pB = i + 2;
      if (pA == -1 || pB == n)
        ans = max(ans, 2);
      else {
        while (pA >= 0 && pB < n) {
          int tmp = a[pA];
          int cnt1 = 0;
          while (pA >= 0 && a[pA] == tmp) {
            pA--;
            cnt1++;
          }
          while (pB < n && a[pB] == tmp) {
            pB++;
            cnt1++;
          }
          if (cnt1 >= 3)
            cnt += cnt1;
          else
            break;
        }
        ans = max(ans, cnt);
      }
    }
  }
  cout << ans << endl;
}
