#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];
  }
  if (sum == x) {
    cout << N << endl;
    return 0;
  }
  int ans = 0;
  sum = 0;
  sort(a, a + N);
  for (int i = 0; i < N; i++) {
    sum += a[i];
    if (sum <= x) {
      ans++;
    }
  }
  if (N == ans) {
    ans--;
  }
  cout << ans << endl;
}
