#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
  int N, x; cin >> N >> x;
  int a[];
  for(int i = 0; i < N; ++i) cin >> a[i];
  sort(a, a + N);
  int peop = 0;

  for(int i = 0; i < N || x < a[i]; ++i){
    x -= a[i];
    ++peop;
  }
  cout << peop << endl;
}
