#include <bits/stdc++.h>
using namespace std;
int n, N[1000000], sum, ans;
int main() {
  scanf("%d%d", &n, &sum);
  for (int i = 1; i <= n; ++i) {
    scanf("%d", &N[i]);
  }
  sort(N + 1, N + 1 + n);
  for (int i = 1; i <= n; ++i) {
    if (sum < N[i])
      break;
    else {
      sum -= N[i];
      ans = i;
    }
  }
  printf("%d", ans);
  return 0;
}
