#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 6, inf = 1e9 + 7;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n, x;
  cin >> n >> x;
  int Arr[n + 2];
  for (int i = 1; i <= n; i++) cin >> Arr[i];
  sort(Arr + 1, Arr + n + 1);
  int Cnt = 0;
  for (int i = 1; i <= n; i++) {
    if (x >= Arr[i]) x -= Arr[i], Cnt++;
  }
  if (x) Cnt--;
  cout << max(0, Cnt) << "\n";
  return 0;
}
