package com.thinker.bishi.quNaEr;


import java.util.Arrays;
import java.util.Scanner;

/**
 * @author lzh
 */
public class Main {

    private static int main(int arr[], int sum) {
        int count = 0;
        if (arr[0] > sum) {
            return -1;
        }
        for (int i = arr.length - 1; i >= 0; i--) {
            if(arr[i] <= sum){
                sum -= arr[i];
                if (sum >= 0) {
                    count++;
                }
                else
                    break;
            }
        }
        return count;
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String[] tmp = sc.nextLine().split(" ");
        int[] arr = new int[tmp.length - 1];
        int sum = Integer.parseInt(tmp[tmp.length - 1]);
        for (int i = 0; i < arr.length; i++) arr[i] = Integer.parseInt(tmp[i]);
        Arrays.sort(arr);
        System.out.println(main(arr, sum));
    }
}
