#!/usr/bin/ python3.8 import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines N, M = map(int, readline().split()) A = tuple(map(int, readline().split())) K = tuple(map(int, readline().split())) M = sum(a * k for a, k in zip(A, K)) - M if M < 0: print(-1) exit() U = 260000 INF = 10 ** 18 dp = [INF] * U dp[0] = 0 for a in A: for i in range(a, U): x = dp[i - a] + 1 if dp[i] > x: dp[i] = x n = A[-1] k = max(0, (M - U) // n + 1) M -= k * n if dp[M] > 10 ** 17: print(-1) else: print(dp[M] + k)