#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k, 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]) {
      k -= arr[i];
      ans++;
    }
    if (k < arr[i]) {
      break;
    }
  }
  cout << ans;
}
