#include <bits/stdc++.h>
using namespace std;
int fact(int n) {
  if (n == 0) return 1;
  return n * fact(n - 1);
}
int gcd(int x, int y) {
  if (x < y) swap(x, y);
  if (y == 0) return x;
  return gcd(y, x % y);
}
int lcm(int x, int y) { return x * y / gcd(x, y); }
bool prime(int n) {
  int cnt = 0;
  for (int i = 1; i <= sqrt(n); i++) {
    if (n % i == 0) cnt++;
  }
  if (cnt != 1)
    return false;
  else
    return n != 1;
}
int a[114];
int n, x, ans = 0, cnt = 0;
signed main() {
  cin >> n >> x;
  for (int i = 0; i < n; i++) cin >> a[i];
  sort(a, a + n);
  for (int i = 0; i < n; i++) cnt += a[i];
  if (cnt >= x) {
    for (int i = 0; i < n; i++) {
      x -= a[i];
      if (x >= 0) ans++;
    }
    cout << ans << endl;
  } else
    cout << n - 1 << endl;
  getchar();
  getchar();
  return 0;
}
