#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, x;
  cin >> N >> x;
  int a[N];
  for (int i = 0; i < N; i++) cin >> a[i];
  sort(a, a + N);
  int sum = 0;
  int stock = x;
  int ans = 0;
  for (int i = 0; i < N; i++) sum += a[i];
  if (sum == x) ans = N;
  if (sum < x) ans = N - 1;
  if (sum > x) {
    for (int i = 0; i < N; i++) {
      if (a[i] <= stock) {
        stock -= a[i];
        ans++;
      }
    }
  }
  cout << ans;
}
