#include <bits/stdc++.h>
using namespace std;
void sort(int a[], int n) {
  int i = 0, j = n - 1;
  int pivot = a[(i + j) / 2];
  while (true) {
    while (a[i] < pivot) i++;
    while (a[j] > pivot) j--;
    if (i >= j) break;
    int hold = a[i];
    a[i] = a[j];
    a[j] = hold;
    i++;
    j--;
  }
  if (i > 1) sort(a, i);
  if (n - j - 1 > 1) sort(a + j + 1, n - j - 1);
}
int main() {
  int N, x;
  int a[101];
  int cnt = 0;
  cin >> N >> x;
  for (int i = 0; i < N; i++) {
    cin >> a[i];
  }
  sort(a, N);
  for (int i = 0; i < N; i++) {
    if (a[i] <= x) {
      cnt++;
      x -= a[i];
    } else {
      break;
    }
  }
  if (x > 0) cnt--;
  if (cnt < 0) cnt = 0;
  cout << cnt << endl;
  return 0;
}
