#include <bits/stdc++.h>
using namespace std;
int CheckDestruction(int x, int i, vector<int> balls) {
  balls.insert(balls.begin() + i, x);
  int res = 0, cntr = 1;
  for (int j = 1; j < balls.size(); ++j) {
    if (balls[j] == balls[j - 1]) {
      cntr++;
    } else {
      if (cntr > 2) {
        res += cntr;
        for (int i = 0; i < cntr; ++i) {
          balls.erase(balls.begin() + j - cntr);
        }
        j = 0;
      }
      cntr = 1;
    }
  }
  if (cntr > 2) {
    res += cntr;
  }
  return res;
}
void CodeForcesA() {
  int n, m;
  cin >> n >> m;
  vector<int> points(n);
  for (auto &member : points) {
    cin >> member;
  };
  {};
  vector<pair<int, int>> intervals(m);
  for (int i = 0; i < m; ++i) {
    cin >> intervals[i].first >> intervals[i].second;
  }
  sort(intervals.begin(), intervals.end());
  vector<int> res;
  bool color = true;
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < m; ++j) {
      if (points[i] >= intervals[j].first && points[i] <= intervals[j].second) {
        if (color) {
          res.push_back(0);
          color = false;
        } else {
          res.push_back(1);
          color = true;
        }
      }
      if (j + 1 < m && points[i] >= intervals[j + 1].first &&
          points[i] <= intervals[j + 1].second) {
        if (color) {
          cout << -1 << "\n";
          return;
        } else {
          break;
        }
      }
      if (j + 1 == m) {
        cout << -1 << "\n";
        return;
      }
    }
  }
  for (auto member : res) {
    cout << member << " ";
  }
  cout << endl;
  ;
}
void CodeForcesB() {
  int n, k, x;
  cin >> n >> k >> x;
  vector<int> balls(n);
  for (auto &member : balls) {
    cin >> member;
  };
  {};
  int res = 0;
  for (int i = 0; i < n; ++i) {
    res = max(res, CheckDestruction(x, i, balls));
  }
  cout << max(0, res - 1) << "\n";
}
int main() {
  ios_base::sync_with_stdio(false);
  CodeForcesB();
  return 0;
}
