#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, s[106], sum;
  scanf("%d%d", &n, &m);
  sum = 0;
  for (int i = 1; i <= n; i++) scanf("%d", &s[i]);
  sort(s + 1, s + 1 + n);
  for (int i = 1; i <= n && m; i++) {
    if (s[i] <= m) sum++, m -= s[i];
  }
  if (sum == 0)
    puts("0");
  else if (m)
    printf("%d", sum - 1);
  else
    printf("%d", sum);
  return 0;
}
