#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 5;
const int mod = 1e9 + 7;
const int inf = (1 << 30);
const int block = 700;
int a[maxn];
int main() {
  ios_base::sync_with_stdio(false);
  int n, x;
  cin >> n >> x;
  for (int i = 1; i <= n; i++) cin >> a[i];
  sort(a + 1, a + n + 1);
  int cnt = 0;
  for (int i = 1; i <= n; i++) {
    if (a[i] <= x) cnt++;
    x -= a[i];
  }
  cout << cnt << endl;
}
