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