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