#include <bits/stdc++.h>
using namespace std;
bool sort_by(pair<int, int> c, pair<int, int> d) { return c.second < d.second; }
int main() {
  int N, x;
  cin >> N >> x;
  int a[N];
  for (int i = 0; i < N; i++) cin >> a[i];
  sort(a, a + N);
  int c = 0;
  for (int i = 0; i < N; i++) {
    if (a[i] > x) break;
    x -= a[i];
    ++c;
  }
  cout << c;
}
