N,K=input().split()
N,K=[int(N),int(K)]
A=list(map(int,input().split()))
F=list(map(int,input().split()))

A=sorted(A)
F=sorted(F,reverse=True)
time=list()

for i in range(N):
   time.append(A[i]*F[i])

goal_max=max(time)
goal_min=0
goal_ave=int((goal_max+goal_min)/2)
goal=int((goal_max+goal_min)/2)

col={"-1":"NG"}
for i in range(goal_max+1):
   col[str(i)]=None

flag=True

while(flag):
   counter=0
   print(goal)
   for i in range(N):
      counter+=(A[i]-int(goal/F[i]))

   if(counter<=K):
      if col[str(goal-1)]=="NG":
         print(goal)
         flag=False
      else:
         col[str(goal)]="OK"
         if goal==int((goal+goal_ave)/2):
            goal=int((goal+goal_ave)/2)-1
            print("b")         
         #elif goal!=goal_ave:
         #   goal=int((goal+goal_ave)/2)
         #   print("a")
         else:
            goal=int((goal+goal_min)/2)
            print("c")

   elif(counter>K):
      if col[str(goal+1)]=="OK":
         print(goal+1)
         flag=False
      else:
         col[str(goal)]="NG"
         if goal==int((goal+goal_ave)/2):
            goal=int((goal+goal_ave)/2)+2
         #elif goal!=goal_ave:
         #   goal=int((goal+goal_ave)/2)    
         else:
            goal=int((goal+goal_max)/2)