#include <bits/stdc++.h>
using namespace std;
int d[1000000];
int dp[1000][1000];
signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a, b;
  int c;
  int e, f, q = 0, w = 0;
  cin >> a >> b;
  for (int i = 0; i < a; i++) {
    cin >> d[i];
    q += d[i];
  }
  if (q <= b) {
    if (q == b)
      cout << a;
    else
      cout << a - 1;
  } else {
    sort(d, d + a);
    for (int i = 0; i < a; i++) {
      if (b - d[i] >= 0) {
        b -= d[i];
        w++;
      }
    }
    cout << w;
  }
  cout << "\n";
}
