#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ii = pair<int, int>;
void in(int &x);
const int N = 105;
const int inf = 1e8;
int n, x, a[N];
map<int, int> dp[N];
int f(int cur, int rem) {
  if (cur > n) return rem == 0 ? 0 : -inf;
  if (dp[cur].count(rem) > 0) return dp[cur][rem];
  int &sol = dp[cur][rem];
  sol = f(cur + 1, rem);
  if (rem >= a[cur]) {
    sol = max(sol, f(cur + 1, rem - a[cur]) + 1);
  }
  return sol;
}
void work() {
  in(n);
  in(x);
  for (int i = 1; i <= n; i++) {
    in(a[i]);
  }
  int DP = f(1, x);
  if (DP < 0) {
    sort(a + 1, a + n + 1);
    int sol = 0;
    for (int i = 1; i <= n; i++) {
      if (x >= a[i]) x -= a[i], sol++;
    }
    if (sol > 0) --sol;
    printf("%d\n", sol);
  } else {
    printf("%d\n", DP);
  }
  return;
}
int main() {
  work();
  return 0;
}
void in(int &x) {
  bool neg = false;
  register int c;
  x = 0;
  c = getchar();
  if (c == '-') {
    neg = true;
    c = getchar();
  }
  for (; c > 47 && c < 58; c = getchar()) x = (x << 1) + (x << 3) + c - 48;
  if (neg) x *= -1;
}
