#include <bits/stdc++.h>
using namespace std;
template <class T>
T gcd(T a, T b) {
  return b ? gcd(b, a % b) : a;
}
const double EPS = 1e-9;
const double PI = acos(-1.);
const int INF = 1e9;
const long long MOD = 1e9 + 7;
const int MAXN = 1e5 + 5;
int a[MAXN];
void solve() {
  int n, x;
  scanf("%d%d", &n, &x);
  for (int i = (0); i < (int)(n); i++) {
    scanf("%d", &a[i]);
  }
  sort(a, a + n);
  int ans = 0;
  for (; ans < n; ans++) {
    if (x >= a[ans]) {
      x -= a[ans];
    } else {
      break;
    }
  }
  if (x) {
    ans--;
    ans = max(ans, 0);
  }
  printf("%d\n", ans);
}
int main() {
  int t = 1;
  while (t--) {
    solve();
  }
}
