#include <bits/stdc++.h>
using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
int N, x;
vector<int> a;
int main() {
  scanf("%d%d", &N, &x);
  a = vector<int>(N);
  for (int i = 0; i < N; ++i) {
    scanf("%d", &a[i]);
  }
  sort(a.begin(), a.end());
  int cnt = 0, i;
  for (i = 0; i < N; ++i) {
    if (x < a[i]) break;
    x -= a[i];
    cnt += 1;
  }
  if (cnt != 0 && x != 0) cnt -= 1;
  if (x + a[i - 1] == a[i]) cnt += 1;
  printf("%d\n", cnt);
  return 0;
}
