#include <bits/stdc++.h>
using namespace std;
int cases = 1;
map<string, int> stin;
map<char, int> chin;
map<int, int> inin;
map<string, string> stst;
map<vector<string>, int> vsin;
struct type {
  type() {}
};
void read(void) { return; }
int rec(vector<int> vct) {
  int ans = 0;
  for (int i = 0; i < (int)vct.size() - 1;) {
    if (vct[i] == vct[i + 1]) {
      int j = i, cnt = 0;
      while (j < (int)vct.size() && vct[j] == vct[i]) j++, cnt++;
      if (cnt > 2) {
        vct.erase(vct.begin() + i, vct.begin() + j);
        ans += rec(vct) + cnt;
      }
    }
    i++;
  }
  return ans;
}
int main() {
  int test_cases, n, k, x;
  while (~scanf("%d %d %d", &n, &k, &x)) {
    int a, ans = 0;
    vector<int> vct, V;
    for (int i = 0; i < n; i++) scanf("%d", &a), vct.push_back(a);
    for (int i = 0; i < (int)vct.size() - 1;) {
      if (vct[i] == vct[i + 1] && vct[i] == x) {
        int j = i, cnt = 0;
        while (j < (int)vct.size() && vct[j] == vct[i]) j++, cnt++;
        if (cnt > 1) {
          V = vct;
          vct.erase(vct.begin() + i, vct.begin() + j);
          int p = rec(vct);
          ans = max(ans, p + cnt);
          vct = V;
          i = j;
        }
      } else
        i++;
    }
    printf("%d\n", ans);
  }
  return 0;
}
