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