implicit none
integer :: n,m,x
integer,allocatable :: a(:),c(:)
integer :: i,j
read *,n,m,x
allocate(a(m))
read *,(a(i),i=1,m)
allocate(c(0:n))
c(:) = 0
do i = 1, m
   c(a(i)) = 1
enddo
i = sum(c(0:x-1))
j = sum(c(x+1:n))
if (i < j) then
   write(6,'(i0)') i
else
   write(6,'(i0)') j
endif
end