if __name__ == "__main__":
    n, x = map(int, input().split())
    aaa = list(map(int, input().split()))
    
    for a in sorted(aaa):
        if x < a:
            break
        ans += 1
        x -= a
    else:
        if x > 0:
            ans -= 1
    print(ans)