#include <bits/stdc++.h>
using namespace std;
void a_candy_distribution_again(void) {
  int n, x;
  int a[100];
  int cnt = 0;
  cin >> n >> x;
  for (int i = 0; i < n; i++) cin >> a[i];
  sort(a, a + n);
  for (int i = 0; i < n; i++) {
    x -= a[i];
    if (x < 0) break;
    cnt++;
  }
  cout << cnt << endl;
}
int main() {
  a_candy_distribution_again();
  return 0;
}
