#include <bits/stdc++.h>
using namespace std;
int dy[] = {0, 0, 1, -1, 0};
int dx[] = {1, -1, 0, 0, 0};
int N, X;
int a[100];
signed main() {
  cin >> N >> X;
  for (int i = 0; i < (N); i++) cin >> a[i];
  sort(a, a + N);
  int ans = 0;
  for (int i = 0; i < (N); i++) {
    if (X >= a[i]) {
      X -= a[i];
      ans++;
    } else {
      X = 0;
      break;
    }
    cout << "X = " << X << "  ans = " << ans << endl;
  }
  if (X > 0) ans = max(ans - 1, 0);
  cout << ans << endl;
  return 0;
}
