#include <bits/stdc++.h>
using namespace std;
int n, x, a[105];
inline int re() {
  char ch = getchar();
  int x = 0, f = 1;
  for (; !isdigit(ch); ch = getchar())
    if (ch == '-') f = -1;
  for (; isdigit(ch); ch = getchar()) x = x * 10 + ch - '0';
  return x * f;
}
int main() {
  n = re();
  x = re();
  for (int i = 1; i <= n; i++) a[i] = re();
  sort(a + 1, a + 1 + n);
  int cnt = 0;
  for (int i = 1; i <= n; i++) {
    if (x >= a[i]) {
      x -= a[i];
      cnt++;
    }
  }
  printf("%d\n", cnt);
  return 0;
}
