n,m = map(int,input().split());a=0 c = list(map(int,input().split())) for i in range(n): if c[i]-m <= 0: a+=1 m-=c[i] print(a)