#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 (x >= a[i]) {
      x -= a[i];
      ++c;
    } else
      break;
  }
  if (x == 0)
    cout << c;
  else
    cout << c - (c > 0 ? 1 : 0);
}
