#include <bits/stdc++.h>
int main() {
  int N, x;
  scanf("%d %d", &N, &x);
  int *a = new int[N];
  for (int i = 0; i < N; ++i) {
    scanf("%d", &a[i]);
  }
  int sum = 0;
  for (int i = 0; i < N; ++i) {
    sum += a[i];
  }
  if (sum == x) {
    std::cout << N << std::endl;
  } else {
    std::sort(a, a + N);
    int a_sum = 0, k = 0;
    for (int i = 0; a_sum + a[i] <= x; ++i) {
      a_sum += a[i];
      k++;
    }
    if (k == N) {
      std::cout << N - 1 << std::endl;
    } else {
      std::cout << k << std::endl;
    }
  }
  return 0;
}
