#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
template <class T>
inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
int gcd(int a, int b) {
  if (b == 0)
    return a;
  else
    return gcd(b, a % b);
}
int lcm(int a, int b) { return a * b / gcd(a, b); }
int sumDight(int x) {
  int sum = 0;
  while (x > 0) {
    sum += (x % 10);
    x /= 10;
  }
  return sum;
}
int divideReverse(int x) {
  int reverse = 0;
  int r;
  while (x > 0) {
    r = x % 10;
    reverse = reverse * 10 + r;
    x /= 10;
  }
  return reverse;
}
int main() {
  cin.tie(0);
  cout.tie(0);
  ios::sync_with_stdio(false);
  int n;
  ll x;
  cin >> n >> x;
  vector<int> d(n);
  for (int i = 0; i < n; i++) {
    cin >> d.at(i);
  }
  sort(d.begin(), d.end());
  int i = 0;
  int sum = 0;
  while (i < n && sum < x) {
    sum += d.at(i);
    i++;
  }
  if (sum == x) cout << i << endl;
  if (sum > x) cout << i - 1 << endl;
}
