# coding=utf-8: n, m = map(int,input().split()) c = list(map(int,input().split())) c.sort(reverse=False) i = 0 while True: if m > c[i]: m -= c[i] c[i] = "0" i += 1 elif m == c[i]: m -= c[i] c[i] = "0" break elif m < c[i]: m -= c[i] c[i] -= m break print(c.count("0"))