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