# Topic : Two-pointer _ 회전 초밥
# 
# PyPy 3 : 시간초과

from collections import deque
import itertools

N , d, k , c = map(int,input().split())
sushi = deque()

for _ in range(N):
  sushi.append(int(input()))

result = 0
for n in range(N):
  cnt = len(set(itertools.islice(sushi,0,k)))
  if not c in itertools.islice(sushi,0,k):
    cnt += 1
  if cnt > result:
    result = cnt
  sushi.rotate(1)

print(result)
# Topic : Two-pointer _ 회전 초밥
# 
# PyPy 3 : 시간 초과

from collections import deque

N , d, k , c = map(int,input().split())
sushi = list()

for _ in range(N):
  sushi.append(int(input()))

array = deque(sushi[:k])
result = len(set(array))

for n in range(N):
  array.append(sushi[(n+k)%N])
  array.popleft()
  
  cnt = len(set(array))
  if not c in array:
    cnt += 1

  if result < cnt:
    result = cnt

print(result)
# Topic : Two-pointer _ 회전 초밥
# 
# PyPy 3 : 실패ㅠ

from collections import deque

N , d, k , c = map(int,input().split())
sushi = list()

for _ in range(N):
  sushi.append(int(input()))

counter = [0] * (d+1)

window = deque()
result , count = 0, 0

for n in range(N+k-1):
  window.append(sushi[n%N])
  counter[sushi[n%N]] += 1
  if counter[sushi[n%N]] == 1:
    count += 1 
  
  if n >= k:

    if counter[c] == 0:
      result = max(result,count+1)
    else:
      result = max(result,count)

    p = window.popleft()
    counter[p] -= 1
    if counter[p] == 0:
      count -= 1
  print(counter)
  print(window,end="  ")
  print(count)

print(result)