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