#include <bits/stdc++.h>
using namespace std;
const int MAXN = 105;
int a[MAXN];
int main() {
  int n, k, ans = 0;
  scanf("%d%d", &n, &k);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  sort(a + 1, a + n + 1);
  for (int i = 1; i <= n; i++) {
    if (k - a[i] >= 0) {
      ans++;
      k -= a[i];
    } else
      break;
  }
  if (k != 0) ans--;
  printf("%d", max(ans, 0));
}
