#include <bits/stdc++.h>
using namespace std;
int main() {
  long long N, x;
  cin >> N >> x;
  vector<long long> a(N);
  for (long long i = 0; i < N; i++) {
    cin >> a[i];
  }
  sort(a.begin(), a.end());
  long long ans = 0;
  long long cnt = 0;
  while (x > 0) {
    if (cnt == N - 1) {
      if (x == a[cnt]) ans++;
      break;
    }
    if (x >= a[cnt]) {
      ans++;
      x -= a[cnt];
    } else
      break;
    cnt++;
  }
  cout << ans;
}
