#include <bits/stdc++.h>
using namespace std;
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());
  int ans = 0;
  while (true) {
    if (x >= a[ans]) {
      x -= a[ans];
      ++ans;
      if (ans == N) {
        break;
      }
    }
    if (x < a[ans]) {
      break;
    }
  }
  cout << ans << endl;
  cin >> N;
}
