#include <bits/stdc++.h>
using namespace std;
const long long INF = (1LL << 60) - 1;
bool isPerfectSquare(long double x) {
  long double sr = sqrt(x);
  return ((sr - floor(sr)) == 0);
}
bool isPrime(long long x) {
  for (long long i = 2; i * i <= x; ++i) {
    if (x % i == 0) return 0;
  }
  return 1;
}
long long fun(long long n) {
  if (n & 1)
    return 3 * n + 1;
  else
    return n / 2;
}
int32_t main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long n, x;
  cin >> n >> x;
  long long arr[n];
  for (long long i = 0; i < n; ++i) cin >> arr[i];
  sort(arr, arr + n);
  long long ans = 0;
  for (long long i = 0; i < n; ++i) {
    if (x - arr[i] >= 0) {
      ans++;
      x -= arr[i];
    }
  }
  if (x > 0 && ans > 0) ans--;
  cout << ans;
}
