#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e2 + 10;
int arr[maxn], n, x, ans = 0;
int main() {
  cin >> n >> x;
  for (int i = 0; i < n; i++) cin >> arr[i];
  sort(arr, arr + n);
  for (int i = 0; i < n; i++) {
    x -= arr[i];
    if (x < 0) ans++;
  }
  if (ans > 0)
    cout << n - ans << endl;
  else if (x > 0)
    cout << n - 1 << endl;
  else
    cout << n << endl;
}
