#include <bits/stdc++.h>
int main() {
  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 count = 0;
  int sum = 0;
  for (int i = 0; i < N; i++) {
    if (sum + a[i] > x) {
      break;
    }
    sum += a[i];
    count++;
  }
  std::cout << count << std::endl;
  return 0;
}
