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