#include <bits/stdc++.h>
const int inf = 1e9 + 7;
const int mod = 1e9 + 7;
using namespace std;
int main() {
  int n, x;
  int a[100];
  cin >> n >> x;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  sort(a, a + n);
  int idx = 0;
  int ans = 0;
  while (idx < n && x - a[idx] >= 0) {
    idx++;
    ans++;
    x -= a[idx];
  }
  if (idx == n && x > 0) {
    ans--;
  }
  cout << ans << endl;
  return 0;
}
