#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, x;
  int a[110];
  int aa = 0;
  cin >> n;
  cin >> x;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    aa += a[i];
  }
  if (aa < x) {
    cout << n - 1 << endl;
    return 0;
  }
  if (aa == x) {
    cout << n << endl;
    return 0;
  }
  int b;
  for (int i = 0; i < n - 1; i++) {
    if (a[i] > a[i + 1]) {
      b = a[i];
      a[i] = a[i + 1];
      a[i + 1] = b;
      i -= 2;
    }
  }
  int answer = 0;
  for (int i = 0; i < n; i++) {
    if (x >= a[i]) {
      x -= a[i];
      answer++;
    } else {
      if (x != 0) {
        answer--;
      }
      break;
    }
  }
  if (answer == -1) {
    answer = 0;
  }
  cout << answer << endl;
  return 0;
}
