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