#include <bits/stdc++.h>
using namespace std;
const int MOD = (int)1e9 + 7;
const int oo = (int)1e9;
const long long OO = (long long)1e18;
const double PI = acos(-1.0);
const int N = (int)1e6 + 9;
bool isprime(int n) {
  if (n <= 1) return 0;
  for (int i = 2; i * i <= n; i++)
    if (n % i == 0) return false;
}
long long intlog(long long base, long long x) { return (log(x) / log(base)); }
bool prime[N];
void primee() {
  for (int p = 2; p * p <= N; p++) {
    if (prime[p] == true) {
      for (int i = p * 2; i < N; i += p) prime[i] = false;
    }
  }
}
string decToBinary(long long n) {
  string z = "";
  int i = 0;
  while (n > 0) {
    z += (n % 2) + 48;
    n = n / 2;
    i++;
  }
  reverse(((z).begin()), ((z).end()));
  return z;
}
int main() {
  int n, x;
  scanf("%d%d", &n, &x);
  vector<int> v(n);
  long long sum = 0;
  for (int i = 0; i < n; i++) {
    scanf("%d", &v[i]);
    sum += v[i];
  }
  if (sum == (long long)x)
    printf("%d\n", n);
  else {
    sort(((v).begin()), ((v).end()));
    int ans = -1;
    for (int i = 0; i < n; i++) {
      x -= v[i];
      if (x >= 0) ans = i;
    }
    if (x > 0)
      printf("%d\n", n - 1);
    else {
      printf("%d\n", ans + 1);
    }
  }
  return 0;
}
