#include <iostream>
#include <algorithm>
using namespace std;
int a[105];
int main() {
  int n,x;
  cin >> n >> x;
  for(int i = 0; i < n; i++) cin >> a[i];
  sort(a,a+n);
  int ans = 0;
  for(int i = 0; i < n-1; i++) {
    if(x >= a[i]) {
      ans++;
      x -= a[i];
    }
  }

  if(x == a[n-1]) ans++;

  cout << ans << endl;
}
