#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.at(i);
  }
  sort(a.begin(), a.end());
  int ans;
  int sum_a = 0;
  for (int i = 0; i < N; i++) {
    sum_a += a.at(i);
    if (sum_a > X) break;
    ans++;
  }
  if (sum_a < X)
    cout << ans - 1 << endl;
  else
    cout << ans << endl;
}
