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