#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, candy;
  cin >> N >> candy;
  vector<int> childs(N);
  for (int i = 0; i < N; i++) {
    int a;
    cin >> a;
    childs[i] = a;
  }
  sort(childs.begin(), childs.end());
  int sum = 0;
  for (int i = 0; i < N; i++) {
    sum += childs[i];
  }
  if (sum == candy)
    cout << N << endl;
  else {
    int i = 0;
    int count = 0;
    while (candy - childs[i] >= 0 && i < N) {
      candy -= childs[i];
      if (candy - childs[i] < childs[i])
        break;
      else {
        i++;
      }
    }
    cout << i << endl;
  }
}
