#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
using mp = map<string, int>;
const int MOD = 1e9 + 7;
const int INF = 1001001001;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n, x;
  cin >> n >> x;
  vector<int> a(n);
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  sort((a).begin(), (a).end());
  int ans = 0;
  for (int i = 0; i < n; ++i) {
    if (x - a[i] < 0) break;
    x -= a[i];
    ans++;
  }
  if (x > 0 && ans > 0) ans--;
  cout << ans << "\n";
  return 0;
}
