#include <iostream>
#include <algorithm>
//using namespace std;
typedef unsigned long long ul;
typedef signed long long ll;

int main(void)
{
  std::cin.tie(0);
  std::ios::sync_with_stdio(false);
  std::cout << std::fixed;
  ll n, m;
  std::cin >> n >> m;
  ll c[n];
  for (ll i = 0; i < n; ++i) std::cin >> c[i];
  std::sort(c, c+n);
  ll removed = 0;
  for (ll i = 0; i < n; ++i) {
    removed += c[i];
    if (removed==m) {std::cout << i+1 << std::endl; return 0;}
    if (removed > m) {std::cout << i << std::endl; return 0;}
  }
  std::cout << n << std::endl;
  return 0;
}