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