#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k, x;
  cin >> n >> k >> x;
  int c[n];
  for (int i = 0; i < n; i++) {
    scanf("%d", &c[i]);
  }
  int m = 0;
  vector<pair<int, int> > vps;
  for (int i = 0; i < n; i++) {
    if (c[i] == x) {
      pair<int, int> p;
      p.first = i;
      int j;
      for (j = i + 1; j < n; j++) {
        if (c[j] != x) {
          break;
        }
      }
      p.second = j - 1;
      vps.push_back(p);
      i = j - 1;
    }
  }
  int ans = 0;
  for (int i = 0; i < vps.size(); i++) {
    int i1, i2;
    i2 = vps[i].second;
    i1 = vps[i].first;
    int s = i2 - i1 + 1;
    if (s >= 2) {
      while (i1 - 1 >= 0 && i2 + 1 < n && c[i1 - 1] == c[i2 + 1]) {
        int cou = 0, num = c[i1 - 1];
        int j;
        for (j = i1 - 1; j >= 0; j--) {
          if (c[j] == num)
            cou++;
          else {
            break;
          }
        }
        i1 = j + 1;
        for (j = i2 + 1; j < n; j++) {
          if (c[j] == num)
            cou++;
          else {
            break;
          }
        }
        i2 = j - 1;
        if (cou >= 3)
          s += cou;
        else
          break;
      }
    } else {
      s = 0;
    }
    if (s > ans) {
      ans = s;
    }
  }
  cout << ans << endl;
  return 0;
}
