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