#include <bits/stdc++.h>
using ll = long long;
ll N, x;
ll a[110];
int main() {
  scanf("%lld%lld", &N, &x);
  for (int i = (0); i < (N); ++i) scanf("%lld", a + i);
  std::sort(a, a + N);
  ll sum = 0, ans = 0;
  for (int i = (0); i < (N); ++i) {
    if (sum + a[i] <= x) {
      sum += a[i];
      ++ans;
    }
  }
  if (ans > 0 && sum != x) --ans;
  printf("%lld\n", ans);
  return 0;
}
