#include <bits/stdc++.h>
int dfs(const std::vector<std::pair<int, int>>& pairs, int l, int r) {
  if (pairs[l].first != pairs[r].first) return 0;
  int size = pairs.size();
  int n = pairs[l].second;
  if (l != r) n += pairs[r].second;
  if (n >= 3) {
    int ll = l - 1, rr = r + 1;
    if (ll >= 0 && rr < size) return dfs(pairs, l - 1, r + 1) + n;
    return n;
  }
  return 0;
}
int main(int argc, char** argv) {
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(0);
  int n, k, x, c[111];
  std::cin >> n >> k >> x;
  for (int i = 0; i < n; i++) std::cin >> c[i];
  std::vector<std::pair<int, int>> pairs = {{c[0], 1}};
  for (int i = 1; i < n; i++)
    if (pairs.back().first == c[i]) {
      pairs.back().second++;
    } else {
      pairs.emplace_back(c[i], 1);
    }
  int cp = 0;
  for (int i = 0, size = pairs.size(); i < size; i++)
    if (pairs[i].first == x) {
      pairs[i].second++;
      cp = std::max(dfs(pairs, i, i) - 1, cp);
      pairs[i].second--;
    }
  std::cout << cp << std::endl;
  return 0;
}
