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