#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100;
int n, a[MAXN], k, ans;
int main() {
  ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  cin >> n >> k;
  for (int i = 1; i <= n; i++) cin >> a[i];
  sort(a + 1, a + n + 1);
  for (int i = 1; i <= n; i++)
    if (k >= a[i])
      k -= a[i], ans++;
    else
      k = 0;
  cout << ans - (k > 0) << endl;
  return 0;
}
