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