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