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