#include <bits/stdc++.h>
using namespace std;
const long long MOD = (1e+9) + 7;
const long long INF = 2e+9 + 10;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N, x;
  cin >> N >> x;
  vector<long long> a(N);
  for (int i = 0; i < N; i++) cin >> a[i];
  sort(a.begin(), a.end());
  int sum = 0;
  for (int i = 0; i < N; i++) sum += a[i];
  if (sum == x) {
    cout << N << "\n";
    return 0;
  }
  int res = 0, i = 0;
  while (x >= a[i]) {
    x -= a[i];
    res++;
    i++;
    if (i == N - 1 && x != a[i]) break;
  }
  cout << res << "\n";
  return 0;
}
