#include <bits/stdc++.h>
using namespace std;
long long int n, x, ar[105];
int32_t main() {
  cin >> n >> x;
  for (long long int i = 1; i <= n; i++) cin >> ar[i];
  sort(ar + 1, ar + n + 1);
  long long int ans = 0;
  for (long long int i = 1; i <= n; i++) {
    if (ar[i] > x) break;
    ans++;
    x -= ar[i];
  }
  if (x > 0) ans -= !!ans;
  cout << ans;
}
