#include <bits/stdc++.h>
using namespace std;
int N, x;
int a[100];
void solve() {
  long long int num = 0, tmp = x;
  sort(a, a + N);
  for (int i = 0; i < N; ++i) {
    if (x >= a[i]) {
      x -= a[i];
      num++;
    }
  }
  if (tmp == x) {
    printf("0\n");
  } else if (x > 0) {
    printf("%d\n", N - 1);
  } else {
    printf("%lld\n", num);
  }
}
int main() {
  cin >> N >> x;
  for (int i = 0; i < N; ++i) {
    cin >> a[i];
  }
  solve();
  return 0;
}
