l = int(input()) n = int(input()) w = map(int,input.split()) ans, tot = 0, 0 for i in range(n): tot += w[i] if tot > l: break ans += 1 print(ans)