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