#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, x;
  cin >> N >> x;
  int a[N];
  long long sum = 0;
  for (int i = 0; i < N; i++) {
    cin >> a[i];
    sum += a[i];
  }
  sort(a, a + N);
  int k = 0;
  if (x > sum)
    cout << N - 1 << endl;
  else if (x == sum)
    cout << N << endl;
  else {
    while (x > 0) {
      x -= a[k];
      if (x == 0) cout << k + 1 << endl;
      if (x < 0) cout << k << endl;
    }
  }
}
