#include <bits/stdc++.h>
using namespace std;
int n, can, arr[111], ans;
int main() {
  scanf("%d %d", &n, &can);
  for (int i = 1; i <= n; i++) scanf("%d", &arr[i]);
  sort(arr + 1, arr + 1 + n);
  for (int i = 1; i < n; i++) {
    if (arr[i] <= can) ans++;
    can -= arr[i];
  }
  printf("%d", ans + (arr[n] == can));
}
