#include <bits/stdc++.h>
int N;
long int x;
int cmpnum(const void *n1, const void *n2) {
  if (*(int *)n1 < *(int *)n2)
    return -1;
  else if (*(int *)n1 > *(int *)n2)
    return 1;
  else
    return 0;
}
int main() {
  int count = 0, j = 0;
  long int cannum[100];
  scanf("%d %ld", &N, &x);
  for (int i = 0; i < N; i++) scanf("%ld", &cannum[i]);
  qsort(cannum, N, sizeof(long int), cmpnum);
  for (j = 0; j < N; j++) {
    if (cannum[j] <= x)
      count++;
    else
      break;
    x -= cannum[j];
  }
  if (x != 0 && count != 0 && j + 1 == N) count--;
  printf("%d\n", count);
  return 0;
}
