#include <bits/stdc++.h>
using namespace std;
int main(void) {
  int N, x;
  int a[110];
  cin >> N >> x;
  for (int i = 0; i < N; i++) cin >> a[i];
  sort(a, a + N);
  int count = 0;
  int sum = 0;
  for (int i = 0; i < N; i++) {
    sum += a[i];
    if (sum > x) break;
    count++;
  }
  cout << count;
  return 0;
}
