#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, x;
  cin >> N >> x;
  vector<int> a(N);
  for (int i = 0; i < N; i++) {
    cin >> a.at(i);
  }
  sort(a.begin(), a.end());
  int rest = x;
  int count = 0;
  int flag = 0;
  for (int i = 0; i < N; i++) {
    x -= a.at(i);
    if (x < 0) {
      flag = 1;
      break;
    }
    count++;
  }
  if (flag == 0) {
    count--;
  }
  cout << count << endl;
}
