#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, x;
  cin >> n >> x;
  long long a[n];
  for (long long i = 0; i < n; i++) {
    cin >> a[i];
  }
  sort(a, a + n);
  int ans = 0;
  long long i = 0;
  while (x >= a[i]) {
    x -= a[i];
    ans++;
    i++;
  }
  cout << ans << endl;
}
