#include <bits/stdc++.h>
using namespace std;
const int N = 355001;
const int SQRTN = 320;
const int LOGN = 20;
const long double PI = acos(-1);
const long double TAU = 2 * PI;
long long sum, n, a[N], x;
signed main() {
  cin >> n >> x;
  for (int i = 0; i < n; i++) {
    scanf("%d", a + i);
    sum += a[i];
  }
  if (sum == x) return cout << n << endl, 0;
  if (sum > x) return cout << n - 1 << endl, 0;
  sort(a, a + n);
  int ans = 0;
  sum = 0;
  for (int i = 0; i < n; i++) {
    sum += a[i];
    if (sum <= x)
      ans++;
    else
      break;
  }
  cout << ans << endl;
}
