#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template <typename T>
using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
const ll inf = 1LL << 60;
vector<int> a;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int N, x;
  cin >> N >> x;
  a.resize(N);
  vector<int> a(N);
  int sum = 0;
  for (int i = 0; i < N; i++) {
    cin >> a[i];
    sum += a[i];
  }
  sort((a).begin(), (a).end());
  if (x > sum)
    cout << N - 1 << endl;
  else if (sum == x)
    cout << N << endl;
  else {
    int ans = 0;
    for (int i = 0; i < N; i++) {
      if (x >= a[i]) {
        x -= a[i];
        ans++;
      }
    }
    cout << ans << endl;
  }
  return 0;
}
