#include <bits/stdc++.h>
using namespace std;
long long n, x, A[1006], ans;
int main() {
  cin >> n >> x;
  for (long long i = 0; i < n; i++) {
    cin >> A[i];
  }
  sort(A, A + n);
  for (long long i = 0; i < n; i++) {
    if (A[i] <= x)
      x -= A[i], ans++;
    else
      break;
  }
  if (x > 0) --ans;
  cout << ans;
}
