#include <bits/stdc++.h>
using namespace std;
int memo[100];
int dp(int now, int sum, int ans);
int n, x, a[100];
int main() {
  fill(memo, memo + 100, -1);
  scanf("%d %d", &n, &x);
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
  }
  sort(a, a + n);
  printf("%d\n", dp(0, 0, 0));
  return 0;
}
int dp(int now, int sum, int ans) {
  if (now == n) {
    if (sum < x)
      return ans - 1;
    else
      return ans;
  }
  if (sum + a[now] > x) return ans;
  return memo[now] =
             max(dp(now + 1, sum, ans), dp(now + 1, sum + a[now], ans + 1));
}
