#include <bits/stdc++.h>
const long long mod = 1000000007;
const long long Inf = 1e9;
using namespace std;
int k, n, m;
vector<int> a;
int getans(int pos) {
  int l = pos + 1, r = l - 1;
  while (l > 0 && a[l - 1] == k) l--;
  while (r < n - 1 && a[r + 1] == k) r++;
  int ans = r - l + 2;
  if (ans > n - 2 || ans < 3) return ans - 1;
  do {
    ans = r - l + 2;
    if (ans == n + 1) return ans - 1;
    int color = l ? a[l - 1] : a[r + 1];
    while (l > 0 && a[l - 1] == color) l--;
    while (r < n - 1 && a[r + 1] == color) r++;
  } while (r - l + 2 - ans > 2);
  return ans - 1;
}
int main() {
  ios::sync_with_stdio(false);
  cin >> n >> m >> k;
  a.resize(n);
  int anss = 0;
  for (int(i) = 0; (i) < n; (i)++) cin >> a[i];
  for (int(i) = 0; (i) < n; (i)++) anss = max(anss, getans(i));
  if (anss > 1)
    cout << anss;
  else
    cout << 0;
  return 0;
}
