#include <bits/stdc++.h>
using namespace std;
const int inf = (int)1e9 + 7;
const int maxn = (int)4e5 + 7;
const int lmaxn = (int)6e5 + 7;
const long long linf = (long long)1e18 + 7;
const long double eps = long double(1e-11);
const long long dx[] = {-1, 0, 0, 1};
const long long dy[] = {0, -1, 1, 0};
long long gcd(long long a, long long b) {
  while (b) a %= b, swap(a, b);
  return a | b;
}
long long lcm(long long a, long long b) { return a * b / gcd(a, b); }
long long k, a[maxn], n, m;
string s;
int main() {
  cin >> n >> m;
  for (int i = 1; i <= n; i++) cin >> a[i];
  sort(a + 1, a + 1 + n);
  for (int i = 1; i <= n; i++) {
    if (m - a[i] >= 0) {
      m -= a[i];
    } else {
      cout << i - 1;
      return 0;
    }
  }
  cout << n;
  return 0;
}
