$l=<>;<>;$a+=0<=($l-=$_)for sort split$",<>;print$a