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