#include <bits/stdc++.h>
using namespace std;
int arr[2000];
int main() {
  int n, num, sum = 0;
  cin >> n >> num;
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
  }
  sort(arr, arr + n);
  for (int i = 0; i < n; i++) {
    if (num >= arr[i]) {
      sum++;
      num -= arr[i];
    } else
      break;
  }
  cout << sum << endl;
  return 0;
}
