#include <bits/stdc++.h>
using namespace std;
const int MaxN = 1e2 + 12;
int n;
int a[MaxN];
int x;
int main() {
  ios_base ::sync_with_stdio(false);
  cin.tie(NULL);
  long long s = 0;
  cin >> n >> x;
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    s += a[i];
  }
  if (s == x)
    cout << n << '\n';
  else if (s > x)
    cout << n - 1 << '\n';
  else {
    sort(a, a + n);
    int res;
    for (res = 0; res < n && a[res] <= x; ++res) x -= a[res];
    cout << res << '\n';
  }
  return 0;
}
