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