#include <bits/stdc++.h>
using namespace std;
int a[10000];
int main() {
  int n, k;
  cin >> n >> k;
  for (register int i = 1; i <= n; i++) scanf("%d", &a[i]);
  sort(a + 1, a + n + 1);
  for (register int i = 1; i <= n; i++)
    if (a[i] > k)
      return !printf("%d\n", i - 1 - (k > 0));
    else
      k -= a[i];
  cout << n - (k > 0);
  return 0;
}
