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