#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, x;
  cin >> N >> x;
  vector<int> a(N);
  int sum = 0;
  for (int i = 0; i < N; i++) {
    cin >> a[i];
    sum += a[i];
  }
  sort(a.begin(), a.end());
  if (sum < x) {
    cout << N - 1;
    return 0;
  }
  if (sum == x) {
    cout << N;
    return 0;
  }
  if (sum > x) {
    int newsum = 0, i = 0;
    for (int i = 0; i < N; i++) {
      newsum += a[i];
      if (newsum == x) {
        cout << i + 1;
        return 0;
      }
      if (newsum > x) {
        cout << i;
        return 0;
      }
    }
  }
}
