#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  int k;
  int arr[n];
  cin >> n >> k;
  for (int i = 0; i < n; i++) {
    int no;
    cin >> no;
    arr[i] = no;
  }
  sort(arr, arr + n);
  int ans = 0;
  for (int i = 0; i < n; i++) {
    if (k > arr[i] & i != n - 1) {
      k -= arr[i];
      ans++;
    } else if (i == n - 1) {
      if (k > arr[i]) {
        break;
      } else if (k == arr[i]) {
        ans++;
        break;
      }
    }
  }
  cout << ans;
}
