L = input() N = input() e = map(int, raw_input().split()) j=0 while L>=0: L = L - e[N-j-1] j = j + 1 else: print j+1