import sys
input=sys.stdin.readline  #危険！基本オフにしろ！

def main():
    n,k=map(int,input().split())
    a=sorted(map(int,input().split()))
    b=sorted(map(int,input().split()),reverse=1)
    #print(a,b)
    ok=max(a)*max(b)
    ng=-1
    
    
            
    while abs(ok-ng)>1:
        mid=(ok+ng)//2
        if sum(a[i]-mid//b[i]for i in range(n) if a[i]*b[i]>mid)<=k:
            ok=mid
        else:
            ng=mid
    print(ok)

if __name__ == '__main__':
    main()
