#include <bits/stdc++.h>
using namespace std;
const int N = 2000100;
const int MOD = (int)pow(10, 9) + 7;
const long long INF = 1LL << 60;
string yn(bool b) { return (b ? "Yes" : "No"); }
string YN(bool b) { return (b ? "YES" : "NO"); }
long long n, x, a[1000], ans;
int main() {
  cin >> n >> x;
  for (long long i = (long long)0; i < (long long)n; ++i) cin >> a[i];
  sort(a, a + n);
  long long sum = 0;
  for (long long i = (long long)0; i < (long long)n; ++i) {
    sum += a[i];
    if (sum > x) break;
    ++ans;
  }
  cout << ans << endl;
  return 0;
}
