#include <bits/stdc++.h>
using ll = long long;
using namespace std;
int a[110];
int main(void) {
  ll N, x;
  cin >> N >> x;
  for (int i = 0; i < N; ++i) {
    cin >> a[i];
  }
  sort(a, a + N);
  int ans = 0;
  for (int i = 0; i < N; ++i) {
    if (x >= a[i]) {
      x -= a[i];
      ans++;
    } else {
      break;
    }
  }
  if (x > 0) ans--;
  cout << max(0, ans) << endl;
  return 0;
}
