#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 101;
int n, x;
int arr[MAX_N];
void solve() {
  int sum = 0;
  scanf("%d%d", &n, &x);
  for (int i = 0; i < n; i++) {
    scanf("%d", arr + i);
    sum += arr[i];
  }
  if (sum == x) {
    printf("%d", n);
    return;
  }
  if (sum > x) {
    sort(arr, arr + n);
    int i = 0;
    while (x > 0) {
      x -= arr[i++];
    }
    if (x < 0)
      printf("%d", i - 1);
    else if (x == 0)
      printf("%d", i);
  } else
    printf("%d", n - 1);
}
int main() {
  solve();
  return 0;
}
