#include <bits/stdc++.h>
using namespace std;
int a[1000];
int main() {
  int n, k, x;
  cin >> n >> k >> x;
  for (int i = int(0); i < int(n); i++) {
    cin >> a[i];
  }
  int i = 0, max = 0, j = 0;
  while (j < n - 1) {
    if (a[j] == x && a[j + 1] == x) {
      int t = j, in = 2, ans = 2;
      while (t - 1 >= 0 && j + in < n) {
        if (a[t - 1] == a[j + in] && a[t - 2] == a[j + in + 1] &&
            a[t - 1] == a[t - 2]) {
          ans = ans + 4;
          t = t - 2;
          in = in + 2;
          continue;
        } else if (a[t - 1] == a[j + in] && a[j + in] == a[j + in + 1]) {
          ans = ans + 3;
          t = t - 1;
          in = in + 2;
          continue;
        } else if (a[t - 1] == a[j + in] && a[t - 1] == a[t - 2]) {
          ans = ans + 3;
          t = t - 2;
          in = in + 1;
          continue;
        } else {
          break;
        }
      }
      if (max < ans) {
        max = ans;
      }
      j = j + 2;
      continue;
    }
    j++;
  }
  cout << max << endl;
  return 0;
}
