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