#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
int sol;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, x;
  cin >> n >> x;
  int a[100];
  for (int i = 0; i < n; ++i) cin >> a[i];
  sort(a, a + n);
  for (int i = 0; i < n; ++i) {
    if (a[i] <= x) x -= a[i], sol++;
  }
  cout << sol;
}
