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