#include <bits/stdc++.h>
using ll = long long;
using P = std::pair<ll, ll>;
constexpr ll INF = 1ll << 60;
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class S, class T>
std::ostream& operator<<(std::ostream& out, const std::pair<S, T>& a) {
  std::cout << '(' << a.first << ", " << a.second << ')';
  return out;
}
template <class T>
std::ostream& operator<<(std::ostream& out, const std::vector<T>& a) {
  std::cout << '[';
  for (ll i = (0); i < (a.size()); ++i) {
    std::cout << a[i];
    if (i != a.size() - 1) std::cout << ", ";
  }
  std::cout << ']';
  return out;
}
ll N, x;
ll a[110];
std::map<ll, ll> dp[110];
int main() {
  std::cin >> N >> x;
  for (ll i = (0); i < (N); ++i) std::cin >> a[i];
  std::sort(a, a + N);
  ll S = 0, ans = 0;
  for (ll i = (0); i < (N); ++i) {
    S += a[i];
    if (S <= x) {
      chmax(ans, (S == x ? i + 1 : i));
    }
  }
  std::cout << ans << std::endl;
  return 0;
}
