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