// Try AtCoder
//author: Leonardone @ NEETSDKASU

fn main() {
	let mut stdin = String::new();
    std::io::Read::read_to_string(
    	&mut std::io::stdin(),
        &mut stdin).unwrap();
	let mut stdin = stdin.split_whitespace();
    let mut get = || stdin.next().unwrap();
    macro_rules! get {
    	($t:ty) => (get().parse::<$t>().unwrap());
        () => (get!(i64));
    }
    
    let n = get!();
    let mut x = get!();
    let mut ks = vec![];
    for _ in 0..n {
    	ks.push(get!());
    }
    ks.sort();
    let mut ans = 0;
    for &k in ks.iter() {
    	if x < k {
        	break;
        }
        x -= k;
        ans += 1;
    }
    if x > 0 {
    	ans -= 1;
    }
    println!("{}", ans);
}