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