#include <bits/stdc++.h>
using ll = long long;
using ull = unsigned long long;
int main(int argc, char *argv[]) {
  int N, x;
  std::cin >> N >> x;
  std::vector<int> a(N);
  for (int i = 0; i < N; i++) {
    std::cin >> a[i];
  }
  std::sort(a.begin(), a.end());
  int ans = 0;
  int i = 0;
  while (x > 0) {
    x -= a[i];
    if (x < 0) {
      break;
    }
    i++;
    ans++;
    if (i == N) {
      break;
    }
  }
  std::cout << ans << std::endl;
  return 0;
}
