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