#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int INF = 1e9;
using P = pair<int, int>;
int main() {
  int n, x;
  cin >> n >> x;
  int a[n];
  for (int i = 0; i < n; i++) cin >> a[i];
  sort(a, a + n);
  int i;
  for (i = 0; i < n; i++) {
    x -= a[i];
    if (x < 0) break;
  }
  cout << i << endl;
}
