#include <bits/stdc++.h>
using namespace std;
const long long MAX = 1000005;
const long long INF = 1e9 + 7;
const long long LINF = 1e18 + 7;
int main() {
  long long n, m;
  cin >> n >> m;
  long long ar[n], ans = 0;
  for (int i = 0; i < n; i++) {
    cin >> ar[i];
  }
  sort(ar, ar + n);
  for (int i = 0; i < n; i++) {
    if (m >= ar[i]) {
      m -= ar[i];
      ans++;
    }
  }
  if (m > 0) {
    ans--;
  }
  if (ans == -1) ans++;
  cout << ans << endl;
  return 0;
}
