#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
long long MOD = 1000000000 + 7;
constexpr long long INF = numeric_limits<LL>::max();
const double PI = acos(-1);
struct Tll {
  LL first, second, third;
};
struct Fll {
  LL first, second, third, fourd;
};
LL h, w, n, m, k, t, s, p, q, last, first, cnt, sum, ans, dp[200000], a[300000],
    b[300000];
string str, ss;
bool f;
char c, ch[100][100];
int di[4][2] = {{0, 1}, {1, 0}, {0, -1}, {-1, 0}};
struct Edge {
  LL to, cost;
};
vector<Edge> vec[200000];
vector<LL> v;
map<LL, LL> ma;
multiset<LL> st;
void YN(bool f) {
  if (f)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
}
void yn(bool f) {
  if (f)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}
int main() {
  cin >> n >> m;
  for (LL i = 0; i < n; i++) {
    cin >> a[i];
  }
  sort(a, a + n);
  for (LL i = 0; i < n; i++) {
    m -= a[i];
    if (m >= 0) {
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}
