#include <bits/stdc++.h>
using namespace std;
using ull = unsigned long long;
using ll = long long;
constexpr int I_INF = INT_MAX;
constexpr ll L_INF = LLONG_MAX;
struct __INIT {
  __INIT() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
  }
} __init;
int main() {
  int N;
  cin >> N;
  ll X;
  cin >> X;
  vector<ll> A(N);
  for (int i = 0; i < N; i++) cin >> A[i];
  sort(A.begin(), A.end());
  int sum = 0;
  for (ll a : A) {
    if (X >= a) {
      X -= a;
      sum++;
    } else
      break;
  }
  if (X != 0 and sum != 0) sum--;
  cout << sum << endl;
}
