#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  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) {
    x -= a[i];
    if (x >= 0) ans++;
  }
  if (x > 0) ans--;
  cout << ans;
  return 0;
}
