#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100 + 10;
long long a[MAXN];
int main() {
  int N, x;
  bool pd = false;
  long long sum = 0, num = 0, maxl = -100;
  cin >> N >> x;
  for (int i = 1; i <= N; i++) cin >> a[i];
  sort(a + 1, a + N + 1);
  for (int i = 1; i <= N; i++) {
    if (a[i] < x) {
      num++;
      x -= a[i];
    } else {
      x == 0;
      break;
    }
  }
  if (x == 0) num--;
  cout << num << "\n";
  return 0;
}
