#include <bits/stdc++.h>
using namespace std;
signed main(void) {
  long long n, x;
  cin >> n >> x;
  priority_queue<long long> g;
  for (long long i = 0; i < n; i++) {
    long long a;
    cin >> a;
    g.push(a);
  }
  long long ans = 0;
  for (long long i = 0; i < n; i++) {
    long long a = g.top();
    g.pop();
    if (i == n - 1) {
      if (a == x) {
        ans++;
        break;
      } else
        break;
    }
    if (a <= x) {
      x -= a;
      ans++;
    } else
      break;
  }
  cout << ans << endl;
}
