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