#include <bits/stdc++.h>
using namespace std;
void solve() {
  int n, colors, color, ans = 0;
  cin >> n >> colors >> color;
  vector<int> main(n);
  vector<int> temp(n);
  for (int i = 0; i < n; i++) {
    cin >> main[i];
    temp[i] = main[i];
  }
  for (int i = 1; i < n; i++) {
    temp.insert(temp.begin() + i, color);
    int ok = 1, sw = 0, index = 105;
    while (ok != 0) {
      ok = 0, index = 105;
      for (int j = 0; j < temp.size() - 1; j++) {
        if (temp[j] == temp[j + 1]) {
          sw++;
          index = min(index, j);
        } else {
          if (sw >= 2) {
            ok = 1;
            temp.erase(temp.begin() + index, temp.begin() + j + 1);
            sw = 0;
            break;
          }
          sw = 0;
          index = 105;
        }
      }
      if (sw >= 2) {
        temp.erase(temp.begin() + index, temp.begin() + temp.size());
      }
      sw = 0;
    }
    ans = max(ans, int(main.size() - temp.size()));
    temp.clear();
    temp = main;
  }
  cout << ans << '\n';
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(0);
  int t = 1;
  while (t--) solve();
}
