#include <bits/stdc++.h>
using namespace std;
int N, x;
vector<int> v;
int main() {
  cin >> N >> x;
  for (int i = 0; i < N; i++) {
    int y;
    cin >> y;
    v.push_back(y);
  }
  sort(v.begin(), v.end());
  int cnt = 0;
  for (int i = 0; i < N; i++) {
    if (x < v[i]) break;
    x -= v[i];
    cnt++;
  }
  cout << cnt << endl;
  return 0;
}
