#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, x;
  cin >> N >> x;
  int a[N];
  for (int i = 0; i < N; i++) cin >> a[i];
  sort(a, a + N);
  int count = 0;
  for (int i = 0; i < N; i++) {
    x -= a[i];
    if (x <= 0) {
      cout << count;
      return 0;
    }
    count++;
  }
  if (x > 0) cout << count - 1;
  return 0;
}
