implicit none
integer :: n,k
integer,allocatable :: a(:),hist(:)
integer :: i

read *,n,k
allocate(a(n))
read *,a

allocate(hist(n))
hist(:) = 0
do i = 1, n
   hist(a(i)) = hist(a(i)) + 1
enddo

call cs11(n,hist)

print '(i0)',n-sum(hist(n-k+1:n))
stop

contains
subroutine cs11(Ncomb,a)
   integer, intent(in) :: Ncomb
   integer, intent(inout) :: a(Ncomb)
   integer :: icomb, jcomb,rswp
   logical :: flg_swp

   icomb = Ncomb
   flg_swp = .false.
   do while (icomb > 1 .or. flg_swp)
      icomb = (icomb * 10) / 13
      if (icomb < 1) then
         icomb = 1
      else if (icomb == 9 .or. icomb == 10) then 
         icomb = 11
      endif
      flg_swp = .false.
      do jcomb = 1, Ncomb-icomb
         if (a(jcomb) > a(jcomb+icomb)) then
            rswp = a(jcomb) 
            a(jcomb) = a(jcomb+icomb)
            a(jcomb+icomb) = rswp
            flg_swp = .true.
         endif
      enddo
   enddo
endsubroutine cs11
end