#include <bits/stdc++.h>
using namespace std;
int a[110];
int n;
int i;
int main() {
  int tmp;
  cin >> n >> tmp;
  for (int i = 1; i <= n; i++) cin >> a[i];
  sort(a + 1, a + n + 1);
  int ans = 0;
  for (i = 1; i <= n; i++) {
    if (tmp >= a[i]) {
      tmp -= a[i];
      ans++;
    } else
      break;
  }
  if (tmp != 0 && ans != 0) ans--;
  cout << ans << endl;
  return 0;
}
