#include <bits/stdc++.h>
using namespace std;
vector<long long int> ls;
long long int eval(long long int n) {
  long long int i, j;
  queue<pair<int, int> > q;
  stack<pair<int, int> > s;
  i = 0;
  long long int ret = 0;
  while (i < n) {
    j = i + 1;
    long long int x, y;
    x = ls[i];
    y = 1;
    while (j < n) {
      if (ls[j] == ls[i]) {
        j++;
        y++;
      } else {
        break;
      }
    }
    q.push(make_pair(x, y));
    i = j;
  }
  while (!q.empty()) {
    long long int x, y;
    x = q.front().first;
    y = q.front().second;
    if (y >= 3) {
      ret += y;
    } else if (s.size() >= 1) {
      if (s.top().first == x) {
        if (s.top().second + y >= 3) {
          ret += s.top().second + y;
          s.pop();
        } else {
          break;
        }
      } else {
        s.push(q.front());
      }
    } else {
      s.push(q.front());
    }
    q.pop();
  }
  if (ret)
    return ret - 1;
  else
    return 0;
}
int main() {
  long long int n, k, x;
  cin >> n >> k >> x;
  for (long long int i = 0; i < n; i++) {
    long long int p;
    cin >> p;
    ls.push_back(p);
  }
  long long int ans = 0;
  for (long long int i = 0; i <= n; i++) {
    vector<long long int>::iterator it = ls.begin() + i;
    ls.insert(it, x);
    ans = max(ans, eval(n + 1));
    it = ls.begin() + i;
    ls.erase(it);
  }
  cout << ans;
}
