#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;
vector<vector<int>> graph(100001, vector<int>());
int main() {
  int n, k;
  cin >> n >> k;
  int a[n];
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  sort(a, a + n);
  int ans = 0;
  for (int i = 0; i < n; i++) {
    if (k >= a[i]) {
      k -= a[i];
      ans += 1;
    }
  }
  cout << ans << endl;
}
