#include <bits/stdc++.h>
using namespace std;
const int N = 105;
int n, x, a[N], s, u;
int main() {
  scanf("%d%d", &n, &x);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]), s += a[i];
  if (s == x) {
    printf("%d", n);
    return 0;
  }
  sort(a + 1, a + n + 1);
  for (int i = 1; i < n; i++) {
    u += a[i];
    if (x < u) {
      printf("%d", i - 1);
      return 0;
    }
  }
  printf("%d", n - 1);
  return 0;
}
