#include <bits/stdc++.h>
using namespace std;
long long a[110];
long long n, x, ans = 0;
int main() {
  scanf("%lld %lld", &n, &x);
  for (int i = 1; i <= n; i++) scanf("%lld", &a[i]);
  sort(a + 1, a + 1 + n);
  for (int i = 1; i <= n; i++)
    if (x >= a[i]) {
      x -= a[i];
      ans++;
    } else
      break;
  if (x > 0 && ans != 0) ans--;
  cout << ans << endl;
  return 0;
}
