#include <bits/stdc++.h>
using namespace std;
const int N = 105;
int n, x, a[N];
int main() {
  scanf("%d%d", &n, &x);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  sort(a + 1, a + 1 + n);
  int ans = 0;
  for (int i = 1; i <= n; i++)
    if (x >= a[i]) {
      ans++;
      x -= a[i];
    } else
      x -= a[i];
  if (x > 0) ans--;
  ans = max(ans, 0);
  printf("%d\n", ans);
}
