#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
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;
  for (int i = 0; i < (N); ++i) {
    int a = A[i];
    if (a > x) break;
    x -= a;
    ++ans;
  }
  cout << ans - (x > 0 ? 1 : 0) << endl;
}
