#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, x, count;
  count = 0;
  cin >> N;
  cin >> x;
  int a[100];
  for (int i = 0; i < N; ++i) cin >> a[i];
  sort(a, a + N);
  for (int i = 0; i < N; ++i) {
    if (x - a[i] < 0) {
      break;
    } else {
      x = x - a[i];
      count++;
    }
  }
  if (x > 0) count--;
  if (count < 0) count = 0;
  printf("%d\n", count);
  return 0;
}
