import java.io.*; import java.util.*; public class Main { static ArrayList>> dp = new ArrayList<>(); static int[] values; public static void main(String[] args) throws Exception { Scanner sc = new Scanner(); int n = sc.nextInt(); int k = sc.nextInt(); values = new int[n]; for (int i = 0; i < n; i++) { dp.add(new HashMap<>()); values[i] = sc.nextInt(); } HashSet ans = dfw(n - 1, k); if (ans == null) { System.out.println(-1); } else { System.out.println(ans.size()); } } static HashSet dfw(int idx, int count) { if (count == 0) { return new HashSet<>(); } if (count < 0 || idx < 0) { return null; } if (!dp.get(idx).containsKey(count)) { HashSet ans1 = dfw(idx - 1, count); HashSet ans2 = dfw(idx - 1, count - values[idx]); if (ans1 == null) { if (ans2 == null) { dp.get(idx).put(count, null); } else { HashSet ans = new HashSet<>(); ans.addAll(ans2); ans.add(idx); dp.get(idx).put(count, ans); } } else { if (ans2 == null) { dp.get(idx).put(count, ans1); } else { HashSet ans = new HashSet<>(); for (int x : ans1) { if (ans2.contains(x)) { ans.add(x); } } dp.get(idx).put(count, ans); } } } return dp.get(idx).get(count); } } class Scanner { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st = new StringTokenizer(""); public Scanner() throws Exception { } public int nextInt() throws Exception { return Integer.parseInt(next()); } public long nextLong() throws Exception { return Long.parseLong(next()); } public double nextDouble() throws Exception { return Double.parseDouble(next()); } public String next() throws Exception { if (!st.hasMoreTokens()) { st = new StringTokenizer(br.readLine()); } return st.nextToken(); } }