#include <bits/stdc++.h>
using namespace std;

int main() {
  int N, x;
  cin >> N >> x;
  int a[100];
  for (int i = 0; i < N; i++) {
    cin >> a[i];
  }
  
  sort(a, a + N, less<int>());
  
  int i = 0;
  if (x >= a[i]) {
    x -= a[i];
    i++;
  }
  else break;
  
  cout << i << endl;
  
}