#include <bits/stdc++.h>
using namespace std;
int main() {
  int N = 0;
  int x = 0;
  int a[101];
  int temp = 0;
  int ans = 0;
  int i = 0;
  int c = 0;
  int check = 0;
  cin >> N >> x;
  for (i = 0; i < N; i++) {
    cin >> a[i];
  }
  for (c = 0; c < N; c++) {
    for (i = 0; i < N - 1; i++) {
      if (a[i] > a[i + 1]) {
        temp = a[i];
        a[i] = a[i + 1];
        a[i + 1] = temp;
      }
    }
  }
  for (i = 0; i < N; i++) {
    if (a[i] <= x) {
      ans++;
      x = x - a[i];
      check = 1;
    }
  }
  if (x == 0 || check == 0) {
    cout << ans << endl;
  } else {
    cout << ans - 1 << endl;
  }
}
