#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  long long n, x, a[110], ans = 0;
  cin >> n >> x;
  for (long long i = 0; i < n; i++) cin >> a[i];
  sort(a, a + n);
  for (long long i = 0; i < n; i++) {
    if (x >= a[i]) {
      ans++;
      x -= a[i];
    } else
      break;
  }
  cout << ans << endl;
  return 0;
}
