#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, x;
  cin >> N >> x;
  int S[110], count = 0;
  for (int i = 0; i < N; i++) cin >> S[i];
  sort(S, S + N);
  for (int i = 0; i < N; i++) {
    x -= S[i];
    if (x < 0) break;
    count++;
  }
  cout << count << endl;
}
