#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, ans = 0;
  long int x, a[100];
  scanf("%d %ld%*c", &N, &x);
  for (int i = 0; i < N; i++) scanf("%ld%*c", &a[i]);
  sort(a, a + N);
  if (x >= accumulate(a, a + N, 0)) {
    ans = N - 1;
    if (x == accumulate(a, a + N, 0)) ans = N;
    printf("%d\n", ans);
    return 0;
  }
  for (int i = 0; i < N; i++) {
    if (x < a[i]) break;
    x -= a[i];
    ans++;
  }
  printf("%d\n", ans);
}
