L = int(input()) N = int(input()) W = list(map(int,input().split())) now = 0 S = 0 while now < N: if S + W[now] <= L: S += W[now] now += 1 print(now)