#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, x, ans = 0;
  vector<int> A;
  cin >> N >> x;
  for (int i = 0; i < N; i++) {
    int a;
    cin >> a;
    A.push_back(a);
  }
  sort(A.begin(), A.end());
  int sum = 0;
  while (sum + A[ans] <= x && ans < N) {
    sum += A[ans];
    ans++;
  }
  cout << ans << endl;
  return 0;
}
