#include <bits/stdc++.h>
int main() {
  long long i, min, mini, out = 0;
  long long N, x, a[100];
  scanf("%lld%lld", &N, &x);
  for (i = 0; i < N; i++) {
    scanf("%lld", &a[i]);
  }
  while (1) {
    for (i = 0, min = 10000000000; i < N; i++) {
      if (a[i] < min && a[i] <= x) {
        min = a[i];
        mini = i;
      }
    }
    if (min != 10000000000) {
      x -= min;
      out++;
      a[mini] = 10000000000;
    } else
      break;
  }
  if (out == 0 || x == 0)
    printf("%lld\n", out);
  else
    printf("%lld\n", out - 1);
  return 0;
}
