#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
long long n, x, a[N], ans;
int main() {
  cin >> n >> x;
  for (int i = 1; i <= n; i++) cin >> a[i];
  sort(a + 1, a + 1 + n);
  a[n + 1] = 1e18;
  for (int i = 1; i <= n + 1; i++) {
    a[i] += a[i - 1];
    if (x < a[i]) {
      if (x == a[i - 1])
        ans = i - 1;
      else
        ans = i - 2;
      break;
    }
  }
  cout << max(0ll, ans) << endl;
  return 0;
}
