#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
const int INF = 2e9 + 5;
int n, x;
int main() {
  cin.sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> x;
  priority_queue<int, vector<int>, greater<int>> q;
  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;
    q.push(a);
  }
  int cnt = 0;
  while (!q.empty()) {
    int u = q.top();
    if (q.top() > x) break;
    q.pop();
    ++cnt;
    x -= u;
  }
  if (x > 0 && cnt > 0) --cnt;
  cout << cnt;
}
