#include <bits/stdc++.h>
using namespace std;
int a[10006];
int main() {
  int n, m, i, j, k, x, l, r;
  cin >> n >> k >> x;
  for (i = 0; i < n; i++) {
    cin >> a[i];
  }
  int ans = 0, mx = 0;
  for (i = 0; i < n - 1; i++) {
    ans = 0;
    if (a[i] == a[i + 1] && a[i] == x) {
      int cnt = 0, ok = 0;
      ans = 2;
      l = i - 1;
      r = i + 2;
      if (a[l] == a[r])
        for (cnt = 2; r < n && l >= 0;) {
          if (a[l - 1] == a[r])
            l--, cnt++;
          else if (a[l] == a[r + 1])
            r++, cnt++;
          else if (cnt < 3)
            break;
          else {
            ans += cnt, cnt = 0;
            if (a[l - 1] == a[r + 1])
              l--, r++, cnt = 2;
            else
              break;
          }
        }
    }
    mx = max(ans, mx);
  }
  cout << mx << endl;
  return 0;
}
