#include <bits/stdc++.h>
using namespace std;
const int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
int N, x;
int a[101];
signed main() {
  cin >> N >> x;
  for (int i = 0; i < N; i++) cin >> a[i];
  sort(a, a + N);
  int i;
  for (i = 0; i < N; i++) {
    if (x < a[i]) break;
    x -= a[i];
  }
  if (x > 0) i--;
  cout << max(0, i) << endl;
  return 0;
}
