#include <bits/stdc++.h>
using namespace std;
int main() {
  int a = 0, b = 0, c = 0, d[100000], e[100000], f = 0, g = 0, h = 0, count = 0;
  char rikka, toka[100000];
  string saya, homu, kyok, mami, mado[100];
  bool gg = false;
  int manji, nk[26] = {false};
  cin >> a >> b;
  for (int i = 0; i < a; i++) {
    cin >> d[i];
  }
  sort(d, d + a);
  for (int j = 0; j < a; j++) {
    if (d[j] <= b) {
      count++;
      b = b - d[j];
    } else {
      cout << count;
      return 0;
    }
  }
  return 0;
}
