#include <bits/stdc++.h>
using namespace std;
const int inf = 0x3f3f3f3f, INF = 0x7fffffff;
const long long infll = 0x3f3f3f3f3f3f3f3fll, INFll = 0x7fffffffffffffffll;
int read() {
  int tmp = 0, fh = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') fh = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    tmp = tmp * 10 + ch - '0';
    ch = getchar();
  }
  return tmp * fh;
}
const int N = 110;
int n, sum, num[N], ans;
int main() {
  n = read(), sum = read();
  for (int i = 1; i <= n; i++) num[i] = read();
  sort(num + 1, num + n + 1);
  ans = 0;
  while (ans < n) {
    if (sum > num[ans + 1]) {
      sum -= num[++ans];
    } else
      break;
  }
  if (ans == n && sum != 0) ans--;
  printf("%d\n", ans);
  return 0;
}
