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