W = int(input()) N = int(input()) blo = list(map(int,input().split())) dig=False s=0 for i in range(N): if dig==True: break else: s +=blo[i] if s>W: dig=True print(i)