#include <bits/stdc++.h>
using namespace std;
const int maxn = 110;
int num[maxn];
int main() {
  int n, x;
  while (~scanf("%d%d", &n, &x)) {
    for (int i = 1; i <= n; i++) {
      scanf("%d", &num[i]);
    }
    sort(num + 1, num + 1 + n);
    int sum = 0;
    for (int i = 1; i <= n; i++) {
      x -= num[i];
      if (x >= 0) {
        if (i != n)
          sum++;
        else if (x == 0)
          sum++;
      }
    }
    cout << sum << endl;
  }
  return 0;
}
