#include <bits/stdc++.h>
const long long maxn = 5e5 + 1, CC = 10001;
using namespace std;
short a[100];
short dp[100][10001];
short sm[10001], pm[10001];
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long n, x;
  cin >> n >> x;
  for (long long i = 0; i < n; i++) cin >> a[i];
  sort(a, a + n);
  for (long long i = 0; i < n; i++) {
    if (a[i] > x) {
      cout << i;
      return 0;
    }
    if (i == n - 1 && a[i] < x) {
      cout << i;
      return 0;
    }
    x -= a[i];
  }
  cout << n;
  return 0;
}
