#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ii = pair<int, int>;
void in(int &x);
const int N = 105;
int n, x, a[N];
void work() {
  in(n);
  in(x);
  int sum = 0;
  for (int i = 1; i <= n; i++) {
    in(a[i]);
    sum += a[i];
  }
  if (x > sum) {
    printf("%d\n", n - 1);
  } else if (x == sum) {
    printf("%d\n", n);
  } else {
    sort(a + 1, a + n + 1);
    int sol = 0, lst = -1;
    for (int i = 1; i <= n; i++) {
      if (x >= a[i]) sol++, x -= a[i], lst = i;
    }
    if (x > 0) {
      if (lst == -1) {
        puts("0");
      } else {
        bool found = 0;
        for (int i = lst + 1; i <= n; i++) {
          if (a[i] == a[lst] + x) {
            found = 1;
          }
        }
        if (!found) --sol;
      }
      printf("%d\n", sol);
    } else {
      printf("%d\n", sol);
    }
  }
  return;
}
int main() { 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;
}
