#include <bits/stdc++.h>
using namespace std;
int const N = 505, MOD = 1e9 + 7;
int n, x, v[N], cnt;
int main() {
  scanf("%d%d", &n, &x);
  for (int i = 0; i < n; ++i) {
    scanf("%d", v + i);
  }
  sort(v, v + n);
  for (int i = 0; i < n; ++i) {
    if (x >= v[i]) {
      x -= v[i];
      ++cnt;
    }
  }
  if (x && cnt) --cnt;
  cout << cnt << "\n";
}
