#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, x;
  cin >> N >> x;
  vector<int> data(N);
  for (int i = 0; i < N; i++) {
    cin >> data[i];
  }
  sort(data.begin(), data.end());
  int count = 0;
  int ans = 0;
  for (int i = 0; i < N; i++) {
    ans += data[i];
    if (ans <= x)
      count++;
    else
      break;
    if (ans == x) break;
  }
  if (ans != x) count--;
  cout << count << endl;
}
