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