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