h,n=map(int,input().split()) rank=sorted([-h]+[-int(input()) for _ in range(n-1)]).index(-h) f=lambda x:rank%10