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