#include <bits/stdc++.h>
using namespace std;
const int N = 105;
priority_queue<long long> q;
int n;
long long m;
long long a[N];
int main() {
  scanf("%d%lld", &n, &m);
  for (int i = 1; i <= n; i++) {
    scanf("%lld", &a[i]);
  }
  sort(a + 1, a + n + 1);
  for (int i = 2; i <= n; i++) q.push(-a[i]);
  int cnt = 0;
  int maxx = a[1];
  while (!q.empty()) {
    if (m >= (-q.top())) {
      cnt++;
      m -= (-q.top());
      q.pop();
    }
    if (m < (-q.top())) break;
  }
  if (m == maxx) cnt++;
  printf("%d\n", cnt);
  return 0;
}
