package main

import (
	"fmt"
	"sort"
)
func main() {
	var n,x int64
	var a []int64
	fmt.Scan(&n,&x)
	nn := n
	for nn >0{
		var i int64
		fmt.Scan(&i)
		a = append(a,i)
		nn --
	}
	//fmt.Scan(&a)
	//n = 3
	//x = 70
	//a = []int64{20,30,10}

	fmt.Println(n,x,a)

	sort.Slice(a, func(i, j int) bool {
		return a[i] < a[j]
	})

	//fmt.Println(a)

	maps := make(map[int64]int64)

	for _,i := range a{
		maps[i] = 0
	}

	for _,i := range a{
		//fmt.Println(x,i)
		if x < i{
			break
		}
		x = x - i
		maps[i] = i
	}
	if x != 0{
		maps[a[0]] = 0
	}

	count := 0
	for k,v := range maps{
		if k == v{
			count++
		}
	}
	fmt.Println(count)
}