#include <bits/stdc++.h>
using namespace std;
int a[200];
signed main() {
  int n, x;
  cin >> n >> x;
  for (int i = 0; i < (n); i++) cin >> a[i];
  sort(a, a + n);
  int cnt = 0;
  for (int i = 0; i < (n); i++) {
    if (x < a[i]) break;
    x -= a[i];
    cnt++;
  }
  if (x) cnt--;
  cout << max(0, cnt) << endl;
}
