#include <bits/stdc++.h>
using namespace std;
const int maxn = 100;
int n, a[maxn + 1], x;
int res;
int main() {
  ios_base::sync_with_stdio(0);
  cin >> n >> x;
  for (int i = 1; i <= n; i++) cin >> a[i];
  sort(a + 1, a + 1 + n);
  res = 0;
  for (int i = 1; i <= n; i++) {
    x -= a[i];
    if (x >= 0) res++;
  }
  if (x > 0) res--;
  cout << res;
  return 0;
}
