#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  vector<int> a;
  int x = 0, n;
  int i = 0, j = 0, in;
  int ans = 0, d;
  cin >> n >> x;
  while (cin >> in) {
    a.push_back(in);
  }
  a.push_back(INT_MAX);
  sort(a.begin(), a.end());
  while (a[i] <= x) {
    if (i != a.size() - 1) {
      x = x - a[i];
      ans++;
      i++;
    } else {
      if (a[i] == x) {
        x = x - a[i];
        ans++;
        i++;
      } else
        x = 0;
    }
  }
  cout << ans << "\n";
}
