#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n, x;
  cin >> n >> x;
  vector<int> v(n);
  for (auto &it : v) cin >> it;
  sort(v.begin(), v.end());
  int ans = 0;
  for (auto it : v) {
    if (it <= x) {
      ans++;
      x -= it;
    }
  }
  cout << ans;
}
