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