#include <bits/stdc++.h>
int main(int argc, char* argv[]) {
  int N = 0;
  long x = 0;
  scanf("%d %ld", &N, &x);
  long* a = new long[N];
  for (int i = 0; i < N; ++i) {
    scanf("%ld", &a[i]);
  }
  std::sort(a, a + N);
  int count = 0;
  for (int i = 0; i < N; ++i) {
    if (x >= a[i]) {
      x -= a[i];
      count++;
    }
  }
  if (x > 0 && count > 0) {
    count--;
  }
  std::cout << count << std::endl;
  return 0;
}
