#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 sum = 0;
  int c = 0;
  for (int i = 0; i < N; i++) {
    sum += AA[i];
    if (sum > X) {
      break;
    }
    c++;
  }
  if (N == c) {
    c--;
  }
  cout << c << endl;
}
