#include <bits/stdc++.h>
using namespace std;
const int Maxn = 100 + 10;
int N, x, A[Maxn];
int main() {
  scanf("%d%d", &N, &x);
  for (int i = 1; i <= N; ++i) scanf("%d", &A[i]);
  sort(A + 1, A + N + 1);
  int sum = 0;
  for (int i = 1; i <= N; ++i) {
    if (A[i] <= x)
      x -= A[i], sum = i;
    else
      break;
  }
  if (x) sum--;
  sum = max(sum, 0);
  cout << sum << endl;
  return 0;
}
