#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int N, x;
  cin >> N >> x;
  priority_queue<long long int, vector<long long int>, greater<long long int> >
      que;
  for (long long int i = 0; i < N; i++) {
    long long int in = 0;
    cin >> in;
    que.push(in);
  }
  long long int ans = 0;
  while (!que.empty() || x > 0) {
    if (x - que.top() >= 0) {
      x -= que.top();
      que.pop();
      ans++;
    } else {
      break;
    }
  }
  if (x > 0 && ans != 0) ans--;
  cout << ans << endl;
}
