"use strict";
const round = [];
let run = 0;
let max = 0;
let first_arr = [];
let last_arr = [];
let dishes;
let kind;
let eat;
let coupon;
let use_coupon = false;
let inputs = require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n");
let first_line = inputs[0].split(' ').map(Number);
dishes = parseInt(first_line[0]);
kind = parseInt(first_line[1]);
eat = parseInt(first_line[2]);
coupon = parseInt(first_line[3]);
inputs.shift();
for (let run = 0; run < inputs.length; run++) {
round.push(inputs[run]);
if (run == eat) first_arr = round.slice();
else if (run == dishes - eat + 2) last_arr = round;
if (round.length == eat + 2) {
use_coupon = false;
setMaxCount(round);
round.shift();
}
}
const arr = last_arr.concat(first_arr);
arr.pop();
let t = [];
let temp;
for (let i = 0; i < last_arr.length + eat - 1; i++) {
t = [];
for (let j = i; j < i + eat + 2; j++) {
if (j > arr.length - 1) temp = j - arr.length;
else temp = j;
t.push(arr[temp]);
}
setMaxCount(t);
}
console.log(max);
function setMaxCount(arr) {
let use_coupon = false;
let temp_max = arr.filter((element, index) => {
if (index > 0 && index < arr.length) {
if (element == coupon) use_coupon = true;
return arr.indexOf(element) === index;
} else return false;
}).length;
if (!use_coupon && (arr[0] == coupon || arr[arr.length - 1] == coupon)) temp_max++;
if (max < temp_max) max = temp_max;
return max;
}