#include <bits/stdc++.h>
using namespace std;
const long long LINF = 1LL << 60;
const int INF = 1001001001;
const int MOD = 1000000007;
int main() {
  int n, x;
  cin >> n >> x;
  vector<int> A(n);
  int sum = 0;
  for (int i = 0; i < (n); i++) {
    cin >> A[i];
    sum += A[i];
  }
  if (sum == x) {
    cout << n << endl;
    return 0;
  }
  sort((A.begin()), (A.end()));
  int ans = 0;
  for (int i = 0; i < (n - 1); i++) {
    x -= A[i];
    if (x >= 0) {
      ans++;
    } else
      break;
  }
  if (ans == n - 1)
    cout << ans - 1 << endl;
  else
    cout << ans << endl;
  return 0;
}
