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