#include <bits/stdc++.h>
using namespace std;
const int N = 105;
int n;
long long m;
int cnt = 0;
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 = n; i >= 2; i--) {
    if (m >= a[i])
      m -= a[i], cnt++;
    else
      break;
  }
  if (m == a[1]) cnt++;
  printf("%d\n", cnt);
  return 0;
}
