#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, x, dis = 0, i = 0, ans = 0;
  cin >> N >> x;
  int a[N];
  for (int k = 0; k < N; k++) {
    cin >> a[k];
  }
  sort(a, a + N);
  while (dis + a[i] <= x && i < N) {
    dis += a[i];
    i++;
    ans++;
  }
  cout << ans << endl;
  return 0;
}
