#include <bits/stdc++.h>
using namespace std;
int a[150000], b[510000], arr[226660];
int main() {
  int n, x, k;
  cin >> n >> k >> x;
  int cnt = 1;
  int l = 0;
  cin >> arr[0];
  for (int i = 1; i < n; i++) {
    cin >> arr[i];
    if (arr[i] == arr[i - 1]) {
      cnt++;
    } else {
      a[l] = arr[i - 1];
      b[l++] = cnt;
      cnt = 1;
    }
  }
  a[l] = arr[n - 1];
  b[l++] = cnt;
  int sum = 0;
  for (int i = 0; i < l; i++) {
    int ans = 0;
    if (a[i] == x) {
      if (b[i] + 1 >= 3) {
        ans += b[i];
        int u = i - 1;
        int v = i + 1;
        while (a[u] == a[v] && b[u] + b[v] >= 3 && u >= 0 && v < n) {
          ans += b[u] + b[v];
          u--;
          v++;
        }
        sum = max(sum, ans);
      }
    }
  }
  printf("%d\n", sum);
}
