#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  long long int candy, gives[10010];
  int ans = 0;
  cin >> n >> candy;
  for (int i = 0; i < n; i++) {
    cin >> gives[i];
  }
  sort(gives, gives + n);
  for (int i = 0; i < n; i++) {
    if (gives[i] <= candy) {
      ans++;
      candy -= gives[i];
    } else {
      break;
    }
  }
  cout << (candy == 0 ? ans : ans == 0 ? ans : ans - 1) << endl;
}
