#include <bits/stdc++.h>
using namespace std;
const int Maxn = 101;
int tot, a[Maxn], n;
int main() {
  cin >> n >> tot;
  for (int i = 1; i <= n; ++i) cin >> a[i];
  stable_sort(a + 1, a + 1 + n);
  for (int i = 1; i <= n; ++i)
    if (a[i] <= tot)
      tot -= a[i];
    else {
      cout << i - 1;
      return 0;
    }
  cout << n;
  return 0;
}
