#include <bits/stdc++.h>
using namespace std;
int N, x;
vector<int> a;
int main() {
  scanf(" %d %d", &N, &x);
  for (int i = 0; i < N; i++) {
    int tmp;
    scanf(" %d", &tmp);
    a.push_back(tmp);
  }
  sort(a.begin(), a.end());
  int result = 0;
  for (int n : a) {
    x -= n;
    if (x > 0) {
      result++;
    } else if (x == 0) {
      result++;
      break;
    } else {
      break;
    }
  }
  if ((x != 0) && (result > 0)) {
    result--;
  }
  printf("%d\n", result);
}
