#include <bits/stdc++.h>
using namespace std;
int main() {
  int m, a, b, k;
  cin >> m >> k >> b;
  int n = m;
  vector<int> arr;
  vector<int> copyarr;
  while (m--) {
    cin >> a;
    arr.push_back(a);
  }
  int ans = 0;
  int i = 0;
  while (i < n) {
    int sum = 0;
    if (arr[i] == arr[i + 1] && arr[i] == b) {
      copyarr = arr;
      copyarr.insert(copyarr.begin() + i, copyarr[i]);
      int stop = 0;
      int j = 0;
      while (j < copyarr.size() && !copyarr.empty()) {
        int t = j;
        while (t < copyarr.size() && copyarr[j] == copyarr[t]) {
          stop = t;
          t++;
        }
        if (stop - j >= 2) {
          copyarr.erase(copyarr.begin() + j, copyarr.begin() + stop + 1);
          sum += stop - j + 1;
          j = 0;
        } else {
          j = stop + 1;
        }
      }
      ans = max(ans, sum - 1);
      i = i + 2;
    } else {
      i++;
    }
  }
  cout << ans << endl;
}
