package main

import (
    "fmt"
    "sort"
)

func main() {
    var n, x int
    fmt.Scan(&n, &x)
    nums := make([]int,n);
    s := 0

    for i := 0; i < n; i++ {
    	fmt.Scan(&nums[i])
    	s+=nums[i]

    }

    if(x==s) {
    	fmt.Println(n)
    	return
    } else if(x<s) {
    	fmt.Println(n-1)
    	return
    }

    sort.Ints(nums)
    ans := 0
    for i := 0; i < n ; i++ {
    	if x>=nums[i] {
    		x-=nums[i]
    		ans++
    	} else {
    		break
    	}    
    }	

	fmt.Println(ans)
}