#include <bits/stdc++.h>
using namespace std;
const int N = 1 << 16;
const int M = 1LL << 30;
const int inf = 1e9 + 7;
const long long INF = 1e18;
const double eps = 1e-6;
const double PI(acos(-1.0));
int n, x;
int a[N];
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cin >> n >> x;
  for (int i = 0; i < (n); i++) {
    cin >> a[i];
  }
  sort(a, a + n);
  int cnt = 0;
  for (int i = 0; i < n; i++) {
    if (x >= a[i])
      x -= a[i], cnt++;
    else
      break;
  }
  cout << cnt << endl;
}
