#include <bits/stdc++.h>
using namespace std;
int main() {
  int x, N;
  int A[1000];
  cin >> N >> x;
  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] < 0)
      break;
    else {
      x -= A[i];
      count++;
    }
  }
  if (count == 0)
    cout << count << endl;
  else {
    if (x != 0)
      cout << count - 1 << endl;
    else
      cout << count << endl;
  }
}
