#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll mod = 1e9 + 7;
int main() {
  int N, x;
  cin >> N >> x;
  vector<int> a(N);
  for (int i = 0; i < N; i++) cin >> a[i];
  sort(a.begin(), a.end());
  if (x < a[0]) {
    cout << 0;
    return 0;
  }
  for (int i = 0; i < N; i++) {
    x -= a[i];
    if (x <= 0) {
      cout << i + 1;
      return 0;
    }
  }
  cout << N - 1;
}
