#include <bits/stdc++.h>
void selection(int a[], int l, int r);
int main(void) {
  int n, x;
  int a[110];
  scanf("%d %d", &n, &x);
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
  }
  selection(a, 0, n);
  int ans = 0;
  for (int i = 0; i < n; i++) {
    x -= a[i];
    if (x >= 0) {
      ans++;
    }
  }
  if (x <= 0 || ans == 0) {
    printf("%d\n", ans);
  } else {
    printf("%d\n", ans - 1);
  }
  return 0;
}
void selection(int a[], int l, int r) {
  for (int i = l; i < r - 1; i++) {
    int min = i;
    for (int j = i + 1; j < r; j++) {
      if (a[j] < a[min]) {
        min = j;
      }
    }
    int t = a[i];
    a[i] = a[min];
    a[min] = t;
  }
}
