#include <bits/stdc++.h>
using namespace std;
int n, k, x;
int b[105], c[105];
int ans;
void dfs(int l, int r, int col) {
  if (l < 0 && r >= n) return;
  if (b[l] == col && b[r] == col) {
    ans += 2;
    dfs(l - 1, r + 1, col);
  } else if (l >= 0 && b[l] == col) {
    ans++;
    dfs(l - 1, r, col);
  } else if (r < n && b[r] == col) {
    ans++;
    dfs(l, r + 1, col);
  }
  if (b[l] == b[r]) {
    if (r + 1 < n && b[l] == b[r + 1]) {
      ans += 3;
      dfs(l - 1, r + 2, b[l]);
    } else if (l - 1 >= 0 && b[l - 1] == b[r]) {
      ans += 3;
      dfs(l - 2, r + 1, b[r]);
    }
  }
}
int main() {
  int maxx = 0;
  cin >> n >> k >> x;
  for (int i = 0; i < n; i++) cin >> b[i];
  for (int i = 1; i < n; i++) {
    ans = 0;
    if (b[i] == x && b[i - 1] == x) {
      ans = 2;
      dfs(i - 2, i + 1, x);
    }
    maxx = max(maxx, ans);
  }
  cout << maxx << endl;
  return 0;
}
