#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, candy;
  cin >> N >> candy;
  int capacity[N];
  for (int i = 0; i < N; i++) {
    cin >> capacity[i];
  }
  sort(capacity, capacity + N);
  int joymen = 0;
  for (int i = 0; i < N; i++) {
    if (candy - capacity[i] >= 0) {
      joymen++;
      candy -= capacity[i];
    } else if (candy != 0 && joymen > 0) {
      joymen--;
      break;
    }
  }
  cout << joymen << endl;
}
