use std::io;
fn read_line() -> String {
    let mut line = String::new();

    io::stdin().read_line(&mut line)
        .expect("Failed to read line");
    return line;
}
fn to_i(s: &str) -> i32 {
    return s.trim().parse()
        .expect("Please type a number!");
}
fn is_even(nums: &Vec<i32>) -> bool{
    for num in nums {
        if num % 2 == 1 {
            return false;
        }
    }
    return true;
}
fn check(index :u32, flags: &mut Vec<bool>, nums: &mut Vec<i32>, val: i32,  s: i32) -> i32 {
    let limit = (nums.len()-1) as u32;
    if index>limit {
        let mut sum = 0;
        let mut count = 0;
        for i in 0..nums.len() {
            if flags[i] {
                sum += nums[i];
                count += 1;
            }
        }
        //println!("nums:{:?} flags:{:?} {} {} {}", nums, flags, count, val ,sum);
        if sum == val {
            return count;
        } else if sum < val {
            return count-1;
        }
        return 0;
    } else {
        
    }

    flags[index as usize] = false;
    let c1 = check(index+1, flags, nums, val, s);
    flags[index as usize] = true;

    let  s2 = s + nums[index as usize];


    let c2 = check(index+1, flags, nums, val, s2);
    if c1>c2 {
        return c1;
    }else {
        return c2;
    }
}
fn main() {

    let l1 = read_line();
    
    let nx: Vec<&str> = l1.split(' ').collect();

    let N: i32 = to_i(nx[0]);
    let x: i32 = to_i(nx[1]);

    let l2 = read_line();
    

    let items: Vec<&str> = l2.split(' ').collect();
    //println!("items:{:?}", items);

    let mut nums: Vec<i32> = Vec::new();

    for item in items {
        nums.push(to_i(item));
    }
    nums.sort();
    nums.reverse();
    //println!("x:{:?}", x);
    //println!("nums:{:?}", nums);
/*
    let mut v:i32 = x.clone();
    let mut count = 0;
    for i in 0..nums.len() {
        if v>=nums[i] {
            v -= nums[i];
            if i==nums.len()-1 {
                if v==0 {
                    count += 1;
                }
            }else {
                count += 1;
            }
            //println!("{} {} {}", count, i, v);
        } else {
            
        }
    }
*/
    let mut flags: Vec<bool> = Vec::new();
    for i in 0..nums.len() {
        flags.push(false);
    }
    let count = check(0, &mut flags, &mut nums, x, 0);


    print!("{}", count);


}   