use std::io;
use std::io::prelude::*;
fn main() {
    let stdin = io::stdin();
    let s1 = readline(&stdin);
    let s2 = readline(&stdin);
    
    let v1: Vec<u32> = s1.split(' ').map(|x| x.parse().expect("parse error")).collect();
    let mut v2: Vec<u32> = s2.split(' ').map(|x| x.parse().expect("parse error")).collect();
    v2.sort();
    let mut x:u32 = v1[1];
    let mut counter = 0;
    for i in v2 {
        if x < i {
            break;
        }
        x = x - i;
        counter = counter + 1;
    }
    if x > 0  && counter > 0{
        counter = counter - 1;
    }
    
    println!("{}", counter);
}

fn readline(stdin: &io::Stdin) -> String {
    stdin.lock().lines().next()
                .expect("input error").unwrap()
}