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