#include <bits/stdc++.h>
using namespace std;
const int rx[] = {0, -1, 0, 1, -1, 1, 1, -1};
const int cy[] = {1, 0, -1, 0, 1, 1, -1, -1};
int chk(vector<int> &na) {
  int p = -1, f = 0;
  int c = 0;
  for (int i = 0; i < (int)(na.size()); i++) {
    if (na[i] > 0) {
      if (na[i] == p) {
        c++;
      } else {
        c = 0;
        p = na[i];
        c++;
      }
      if (c >= 3) {
        for (int j = i; j >= 0; j--) {
          if (na[j] > 0) {
            if (na[j] == p)
              na[j] = -1;
            else
              break;
          }
        }
        for (int j = i + 1; j < (int)(na.size()); j++) {
          if (na[j] > 0) {
            if (na[j] == p)
              na[j] = -1;
            else
              break;
          }
        }
        return 1;
      }
    }
  }
  return 0;
}
int main() {
  int n, k, x, tmp, c;
  int res = INT_MIN;
  cin >> n >> k >> x;
  vector<int> a, vis(n, 0);
  vector<int> nn;
  for (int i = 0; i < n; i++) {
    scanf("%d", &tmp);
    a.push_back(tmp);
    nn.push_back(tmp);
    nn.push_back(-1);
  }
  for (int i = 0; i < n; i++) {
    if (a[i] == x) {
      vector<int> na;
      for (int j = 0; j < (int)(nn.size()); j++) na.push_back(nn[j]);
      na[2 * i + 1] = x;
      while (chk(na)) {
      }
      c = 0;
      for (int j = 0; j < (int)(na.size()); j++)
        if (na[j] != -1) c++;
      res = max(res, (n - c) < 0 ? 0 : (n - c));
    }
  }
  cout << res << endl;
  return 0;
}
