#include <bits/stdc++.h>
using namespace std;
long long int happy[105], mintomax[105];
int main() {
  long long int k, c;
  cin >> k >> c;
  long long int totalhappy = 0;
  for (int i = 1; i <= k; i++) {
    cin >> happy[i];
    totalhappy = totalhappy + happy[i];
  }
  long long int maxhappy = 0, candyused = 0;
  if (totalhappy == c) {
    cout << k;
  } else if (totalhappy < c) {
    cout << k - 1;
  } else {
    long long int min = 1000000005;
    for (int i = 1; i <= k; i++) {
      for (int j = 1; j <= k; j++) {
        if (happy[j] < min && happy[j] >= mintomax[i - 1] && happy[j] != 0) {
          mintomax[i] = happy[j];
          min = happy[j];
          happy[j] = 0;
        }
      }
      min = 1000000005;
    }
    for (int i = 1; i <= k; i++) {
      candyused = candyused + mintomax[i];
      if (candyused <= c) {
        maxhappy++;
      } else {
        break;
      }
    }
    cout << maxhappy;
  }
}
