#include <bits/stdc++.h>
using namespace std;
int A[202020], n, x;
int main() {
  scanf("%d %d", &n, &x);
  for (int i = 1; i <= n; i++) scanf("%d", &A[i]);
  sort(A + 1, A + n + 1);
  int ans = n;
  for (int i = 1; i <= n; i++) {
    if (A[i] > x) {
      ans = i - 1;
      break;
    }
    x -= A[i];
  }
  if (x && ans) ans--;
  cout << ans;
}
