#include <bits/stdc++.h>
using namespace std;
int n, m, ans;
int a[110];
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  sort(a + 1, a + n + 1);
  int now = m;
  for (int i = 1; i <= n; i++) {
    if (m < a[i]) break;
    if (m >= a[i]) m -= a[i], ans++;
  }
  if (m != 0 && now > a[1]) ans--;
  printf("%d\n", ans);
  return 0;
}
