#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll Mod = 1000000007;
int main() {
  int N;
  ll x;
  ll a[N];
  cin >> N >> x;
  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 (x >= a[i]) {
      ans++;
      x -= a[i];
    }
  }
  if (x != 0 && ans == N) {
    ans--;
  }
  cout << ans << endl;
  return 0;
}
