N, X = map(int, input().split())
A = [int(x) for x in input().split()]
count = 0
m = 0
def Candy (i, rest, count):
    global m
    #print(i, rest, count)
    #最後に余った
    if i == N and rest > 0:
        #print("remain")
        if count > 0:
            m = max(m, count - 1)
            return m
        else:
            m = max(m, count)
            return m

    #最後に余らなかった
    if i == N and rest == 0:
        #print("just")
        m = max(m, count)
        return m

    if i == N and rest < 0:
        #print("over")
        return False
    
    #配って次へ   
    if (Candy(i+1, rest-A[i], count+1)):
        #print("A", i, rest, count)
        return True
  
    #配らないで次へ
    if (Candy(i+1, rest, count)):
        #print("B", i, rest, count)
        return True
    
    return False
Candy(0, X, count)
print(m)
