from bisect import bisect_left as bl n,k = map(int,input().split()) ns=list(map(int,input().split())) ns.sort() ans=0 for i in range(5,-1,-1): t=n-bl(ns,i) if t > k: break ans=t print(ans)