#include <bits/stdc++.h>
using namespace std;
const int MAXN = 105;
int n, x, a[MAXN];
int main() {
  cin >> n >> x;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  sort(a + 1, a + n + 1);
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    if (i != n) {
      if (x - a[i] >= 0) {
        x -= a[i];
        ++ans;
      }
    } else {
      if (x == a[i]) ++ans;
    }
  }
  cout << ans << endl;
  return 0;
}
