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