#include <bits/stdc++.h>
using namespace std;
const long long INF = (1LL << 60) - 1;
const long long maxN = 1000001;
int32_t main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long n, x;
  cin >> n >> x;
  long long arr[n];
  long long sum = 0;
  for (long long i = 0; i < n; i++) {
    cin >> arr[i];
  }
  sort(arr, arr + n);
  for (long long i = 0; i < n; i++) {
    if (x >= arr[i]) {
      x -= arr[i];
      sum++;
    }
  }
  if (sum == x and x > 0) {
    sum--;
  }
  cout << sum << "\n";
}
