fn main(){
  let nx: Vec<u32> = read_vec();
  let n = nx[0];
  let x = nx[1];
  let mut a: Vec<u32> = read_vec();
  
  a.sort();
  let (ct, rm) = a.iter().fold((0,x), |(c, r), &u| if r >= u {(c+1, r-u)} else {(c, r)});
  let ans = if rm > 0 {ct - 1} else {ct};
  
  println!("{}", ans);
}

fn read_vec<T>() -> Vec<T>
  where T: std::str::FromStr,
        T::Err: std::fmt::Debug
{
  let mut buf = String::new();
  std::io::stdin().read_line(&mut buf).expect("failed to read");
  buf.split_whitespace().map(|e| e.parse().unwrap()).collect()
}
