#include <bits/stdc++.h>
using namespace std;
const int N = 110;
inline int read() {
  int p = 0;
  int f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    p = p * 10 + ch - '0';
    ch = getchar();
  }
  return p * f;
}
int a[N];
int n;
int main() {
  n = read();
  int k = read();
  for (int i = 1; i <= n; i++) a[i] = read();
  sort(a + 1, a + n + 1);
  int l = 1;
  while (l <= n && a[l] <= k) {
    k -= a[l];
    l++;
  }
  if (l == n + 1 && k) l -= 2;
  printf("%d\n", l);
  return 0;
}
