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