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