#include <bits/stdc++.h>
using namespace std;
bool IsPrime(long long int num) {
  if (num < 2)
    return false;
  else if (num == 2)
    return true;
  else if (num % 2 == 0)
    return false;
  long double sqrtNum = sqrt(num);
  for (long long int i = 3; i <= sqrtNum; i += 2) {
    if (num % i == 0) return false;
  }
  return true;
}
long long int KSum(long long int n) {
  long long int sum = 0;
  if (n < 0) return 0;
  while (n > 0) {
    sum += n % 10;
    n /= 10;
  }
  return sum;
}
bool KReve(long long int n) {
  int reverse = 0;
  int remaind;
  int tmp = n;
  while (tmp != 0) {
    remaind = tmp % 10;
    reverse = reverse * 10 + remaind;
    tmp /= 10;
  }
  if (reverse == n)
    return true;
  else
    return false;
}
int main(void) {
  ios::sync_with_stdio(false);
  long long int N;
  cin >> N;
  long long int x;
  cin >> x;
  vector<long long int> a(N);
  for (long long int i = 0; i < N; i++) {
    cin >> a.at(i);
  };
  sort(a.begin(), a.end());
  long long int s = 0;
  for (long long int i = 0; i < N; i++) {
    if (x - a[i] >= 0) {
      x -= a[i];
      s++;
    }
  }
}
