package main

import (
    "fmt"
    "sort"
)

func main() {
    var n, x int
    fmt.Scan(&n, &x)
    nums := make([]int,n);
    for i := 0; i < n; i++ {
    	fmt.Scan(&nums[i])
    }
    sort.Ints(nums)

    ans := 0
    r := -1
    for i := 0; i < n ; i++ {
    	if x>=nums[i] {
    		x-=nums[i]
    		ans++
    	} else { 
    		r = nums[i]-x		
	    	break
    	}
    }

    if r>0 && ans>0 {
    	ans--
    	for i := 0; i < n; i++ {
    		if r==nums[i] {
    			x=0
    			ans++
    			break
    		}
    	}
    }

    if x>0 && ans>0{
    	ans--
    }

	fmt.Println(ans)
}