#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, x, k, ans = 0;
  vector<int> v;
  scanf("%d %d", &n, &x);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &k);
    v.push_back(k);
  }
  sort(v.begin(), v.end());
  for (int i = 0; i < n; i++) {
    if (x - v[i] >= 0) ans++, x -= v[i];
  }
  if (x == 0)
    printf("%d", ans);
  else
    printf("%d", max(ans - 1, 0));
}
