#include <bits/stdc++.h>
using namespace std;
int n, x, a, chk = -1, mx = -1;
vector<int> v;
int main() {
  scanf("%d%d", &n, &x);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a);
    v.push_back(a);
  }
  sort(v.begin(), v.end());
  while (v.back() > x && v.size() != 0) {
    v.pop_back();
  }
  if (v.size() == 0) {
    printf("0");
  } else {
    for (int i = 0; i < v.size(); i++) {
      if (i != 0) {
        v[i] = v[i - 1] + v[i];
      }
    }
    for (int i = v.size(); i >= 1; i--) {
      if (v[i - 1] <= x) {
        chk = v[i - 1];
        mx = i;
        break;
      }
    }
    if (chk == x) {
      printf("%d", mx);
    } else
      printf("%d", mx);
  }
}
