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