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