#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1001001001;
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 sum = 0;
  for (int i = 0; i < N; i++) {
    sum += a.at(i);
  }
  int count = 0;
  if (x < sum) {
    while (x >= 0) {
      int i = 0;
      x -= a.at(i);
      i++;
      count++;
    }
    cout << count - 1 << endl;
  } else if (x == sum) {
    cout << N << endl;
  } else {
    cout << N - 1 << endl;
  }
  return 0;
}
