#include <bits/stdc++.h>
using namespace std;
const int inf = (int)1e9;
const int mod = inf + 7;
long long n, x;
long long a[111];
int main() {
  ios_base ::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> x;
  for (int i = 0; i < n; ++i) cin >> a[i];
  sort(a, a + n);
  long long sum = 0, ans = 0;
  for (int i = 0; i < n; ++i) {
    if (sum + a[i] > x)
      break;
    else {
      sum += a[i];
      ++ans;
    }
  }
  cout << ans;
  return 0;
}
