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