#include <bits/stdc++.h>
using namespace std;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(9);
  int N, x;
  cin >> N >> x;
  vector<int> a;
  for (int i = 0; i < N; i++) {
    int tmp;
    cin >> tmp;
    a.push_back(tmp);
  }
  sort(a.begin(), a.end());
  int ans = 0;
  int now = 0;
  while (now < N && x >= a[now]) {
    x -= a[now];
    now++;
    ans++;
  }
  if (x == 0)
    cout << ans << endl;
  else
    cout << max(ans - 1, 0) << endl;
  return 0;
}
