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