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