use std::io::stdin;

fn main() {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    let mut iter = buf.split_whitespace();
    let n: u32 = iter.next().unwrap().parse().unwrap();
    let x: u32 = iter.next().unwrap().parse().unwrap();

    buf.clear();
    stdin().read_line(&mut buf).unwrap();
    let iter = buf.split_whitespace();
    let mut sweets_number: Vec<u32> = Vec::new();
    for str in iter{
        sweets_number.push(str.parse::<u32>().unwrap());
    }

    println!("{}", solve(n, x, sweets_number))
}

fn solve(n: u32, x: u32, mut sweets_number: Vec<u32>) -> u32{
    let sum: u32 = sweets_number.iter().sum();
    if sum == x{
        return n;
    }
    if sum < x {
        return n -1;
    }

    sweets_number.sort();
    if sweets_number[0] > x{
        return 0;
    }

    let mut sweets_iter = sweets_number.iter();
    let mut counter = 0;
    let mut sum = 0;
    while sum < x{
        counter += 1;
        sum += *(sweets_iter.next().unwrap());
    }
    counter
}