#include <bits/stdc++.h>
using namespace std;
using vec = vector<int>;
using intk = int64_t;
int main() {
  int N, X;
  cin >> N >> X;
  vec a(N);
  for (int i = 0; i < N; i++) cin >> a[i];
  sort(a.begin(), a.end());
  int ans = 0;
  for (int i = 0; i < N; i++) {
    if (X < a[i])
      break;
    else {
      X - a[i];
      ans++;
    }
  }
  printf("%d\n", ans);
}
