#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
ll MOD = 1000000007;
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++) {
    if (x >= A[i]) {
      ans++;
      x -= A[i];
    }
  }
  if (x == 0 || ans == 0)
    cout << ans;
  else
    cout << ans - 1;
}
