#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main() {
  int n, x;
  cin >> n >> x;
  vector<int> a(n);
  for (int i = 0; i < (n); i++) cin >> a[i];
  sort(begin(a), end(a));
  int ans = 0;
  for (int i = 0; i < (n); i++) {
    x -= a[i];
    if (x < 0) break;
    ans++;
  }
  cout << ans << endl;
  return 0;
}
