let input = readLine()!.characters.split(" ").map{Int(String($0))!}
let N = input[0]
var x = input[1]
let a = readLine()!.characters.split(" ").map{Int(String($0))!}.sort()
var ans = 0
for i in 0..<N {
  x -= a[i]
  if x == 0 {
    ans = i
  } else if x < 0 {
    ans = i - 1
  }
}
print(x>0 ?N-1:ans)