#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e2 + 10;
int arr[maxn], n, x, ans = 0;
int main() {
  cin >> n >> x;
  for (int i = 0; i < n; i++) cin >> arr[i];
  sort(arr, arr + n);
  for (int i = 0; i < n; i++)
    if (arr[i] <= x) x -= arr[i], ans++;
  if (ans == 0)
    cout << ans << endl;
  else if (x >= 0)
    cout << ans << endl;
  else
    cout << ans - 1 << endl;
}
