#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int t = 1;
  while (t--) {
    long long int n, x;
    cin >> n >> x;
    long long int a[n];
    for (long long int i = 0; i < n; i++) cin >> a[i];
    sort(a, a + n);
    for (long long int i = 1; i < n; i++) a[i] += a[i - 1];
    long long int p = lower_bound(a, a + n, x) - a;
    if (p >= n)
      cout << n;
    else if (a[p] > x)
      cout << p;
    else if (a[p] == x)
      cout << p + 1;
  }
}
