#include <bits/stdc++.h>
using namespace std;
int main(void) {
  int N, x;
  cin >> N >> x;
  vector<int> child(N, 0);
  for (int i = 0; i < N; i++) {
    cin >> child[i];
  }
  sort(child.begin(), child.end());
  int ans = 0;
  int candy = 0;
  for (int i = 0; i < N; i++) {
    candy += child[i];
    if (candy > x)
      break;
    else
      ans++;
  }
  cout << ans << endl;
  return 0;
}
