N = int(input()) B = int(input()) C = list(map(int, input().split())) S = list(map(int, input().split())) # 価格操作 smax = 0 idx = -1 for i in range(N): if S[i] > smax: idx = i smax = S[i] C[idx] = 1 CS = [(C[i],S[i]) for i in range(N)] CS.sort(key = lambda x:x[0]) ans = 0 for i in range(N): cost, pcs = CS[i] buy = min(B//cost, pcs) B -= buy * cost ans += buy print(ans)