#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, X;
  cin >> N >> X;
  std::vector<int> v;
  for (int i = 1; i <= N; ++i) {
    int x;
    scanf("%d", &x);
    v.push_back(x);
  }
  sort(v.begin(), v.end());
  signed long long int res = 0;
  int ans = 0;
  for (int i = 0; i < N; ++i) {
    if (res + v[i] <= X) res += v[i], ans++;
  }
  if (res != X) ans--;
  ans = max(ans, 0);
  cout << ans;
}
