#include <bits/stdc++.h>
using namespace std;
const int N = 110;
int n, k, x;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n >> k >> x;
  vector<int> c(n);
  for (int i = 0; i < n; i++) cin >> c[i];
  int res = 0;
  for (int i = 0; i < n; i++) {
    if (c[i] == x) {
      int cur = 0;
      vector<int> v = c;
      v.insert(v.begin() + i, x);
      while (true) {
        bool found = false;
        for (int j = 0; j < (int)(v).size(); j++) {
          int cnt = 0;
          int k = j;
          while (k < (int)(v).size() && v[j] == v[k]) {
            k++;
            cnt++;
          }
          if (cnt >= 3) {
            v.erase(v.begin() + j, v.begin() + k);
            found = true;
            break;
          }
        }
        if (found == false) break;
      }
      res = max(res, n - (int)(v).size());
    }
  }
  while (true) {
    bool found = false;
    for (int j = 0; j < (int)(c).size(); j++) {
      int cnt = 0;
      int k = j;
      while (k < (int)(c).size() && c[j] == c[k]) {
        k++;
        cnt++;
      }
      if (cnt >= 3) {
        c.erase(c.begin() + j, c.begin() + k);
        found = true;
        break;
      }
    }
    if (found == false) break;
  }
  res = max(res, n - (int)(c).size());
  cout << res;
  return 0;
}
