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