#include <bits/stdc++.h>
using namespace std;
const int maxn = 200100;
int a[maxn], s[maxn];
int main() {
  int n, x;
  cin >> n >> x;
  for (int i = 0; i < n; i++) cin >> a[i];
  sort(a, a + n);
  int k = 0;
  for (int i = 0; i < n; i++)
    if (x >= a[i]) {
      x -= a[i];
      s[i] = 1;
      k++;
    }
  if (x > 0) {
    int way = -1;
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < n; j++) {
        if (s[i] == 1 && s[j] == 0) {
          if (x + a[i] - a[j] == 0) way = 0;
        }
      }
    }
    k += way;
  }
  if (k < 0) k = 0;
  cout << k << endl;
  return 0;
}
