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