#include <bits/stdc++.h>
using namespace std;
signed main() {
  long long n;
  long long x;
  long long a[101];
  long long ans = 0;
  cin >> n;
  cin >> x;
  for (long long i = 0; i < n; i++) {
    cin >> a[i];
  }
  sort(a, a + n);
  for (long long i = 0; i < n; i++) {
    if (a[i] <= x) {
      x -= a[i];
      ans++;
    } else
      break;
  }
  if (x != 0 && ans != 0) ans--;
  cout << ans;
  return 0;
}
