#include <bits/stdc++.h>
using namespace std;
int a[400020];
int n, x;
int sum = 0;
int main() {
  cin >> n >> x;
  int tmp = x;
  for (int i = 1; i <= n; ++i) {
    scanf("%d", &a[i]);
    sum += a[i];
  }
  sort(a + 1, a + n + 1);
  int ans = 0;
  for (int i = 1; i <= n; ++i) {
    if (x >= a[i]) {
      ans++;
      x -= a[i];
    }
  }
  if (sum < tmp) ans--;
  cout << ans << endl;
  return 0;
}
