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