#include <bits/stdc++.h>
using namespace std;
int main(void) {
  int n;
  long long int x;
  long long int nums[100];
  int count = 0;
  long long int sum = 0;
  cin >> n >> x;
  for (int i = 0; i < n; i++) {
    cin >> nums[i];
  }
  while (true) {
    int min = -1;
    int mini = -1;
    for (int i = 0; i < n; i++) {
      if ((min == -1 || min > nums[i]) && nums[i] != -1) {
        min = nums[i];
        mini = i;
      }
    }
    if (mini != -1) {
      sum += min;
      if (sum > x) {
        break;
      }
      count += 1;
      nums[mini] = -1;
    } else {
      count -= 1;
      break;
    }
  }
  cout << count << endl;
  return 0;
}
