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