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