#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll mod = 1000000007;
const int INF = INT_MAX / 2;
int main() {
  int N, x;
  cin >> N >> x;
  vector<int> v(N);
  for (int i = 0; i < N; i++) cin >> v[i];
  sort(v.begin(), v.end());
  int ans = 0;
  for (int i = 0; i < N; i++) {
    x -= v[i];
    if (x >= 0) {
      ans++;
    } else {
      break;
    }
  }
  cout << ans << endl;
}
