#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using P = pair<int, int>;
int main() {
  int N, x;
  cin >> N >> x;
  vector<int> a(N);
  for (int i = 0; i < (int)(N); i++) cin >> a[i];
  sort(a.begin(), a.end());
  int ans = 1;
  for (int i = 0; i < (int)(N); i++) {
    if (x >= a[i]) {
      ans++;
      x -= a[i];
    }
  }
  if (x > 0) ans--;
  cout << ans << endl;
}
