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