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