#include <bits/stdc++.h>
using namespace std;
const static long long int MOD = 1000000000 + 7;
const static int dy[] = {0, 1, 0, -1};
const static int dx[] = {1, 0, -1, 0};
int main(int argc, char *argv[]) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, x, a[101];
  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] < 0) break;
    x -= a[i];
    ++ans;
  }
  cout << ans << endl;
  return 0;
}
