#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 = i + 1) {
    cin >> a.at(i);
  }
  sort(a.begin(), a.end());
  int sum = 0;
  int count;
  for (int i = 0; i < N; i = i + 1) {
    sum = sum + a.at(i);
    if (sum <= x)
      count = i;
    else if (sum > x) {
      count = i - 1;
      break;
    }
  }
  cout << count << endl;
}
