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