l = int(input()) n = int(input()) a = list(map(int,input().split())) tot = 0 for i in range(n): tot += a[i] if tot > l: print(i) exit() print(n)