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