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