#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, x, ans = 0;
  int a[110];
  cin >> N >> x;
  for (int i = 0; i < N; ++i) cin >> a[i];
  sort(a, a + N);
  for (int i = 0; i < N; ++i) {
    x = x - a[i];
    if (x >= 0) ans++;
  }
  if (ans == N && x > 0) --ans;
  cout << ans << endl;
}
