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