n,k = list(map(int,input().split()))

a = list(map(int,input().split()))

b = list(map(int,input().split()))

a.sort()

b.sort(reverse=True)

#print(a)

#print(b)

big = 44

stand = 2 ** big

width = 2 ** (big-1)

if sum(a) <= k:

  print((0))

else:

  while True:

    tmp = []

    for i in range(n):

       tmp.append(max(0,a[i]-stand//b[i]))

    if width == 0:

      if sum(tmp) <= k:

        print(stand)

      else:

        print((stand+1))

      break

    if sum(tmp) <= k:

      stand -= width

      width //= 2

    else:

      stand += width

      width //= 2

    #print(stand,tmp)
n,k = list(map(int,input().split()))

a = list(map(int,input().split()))

f = list(map(int,input().split()))

a.sort()

f.sort(reverse=True)

#print(a)

#print(f)

scale = 42

aim = 2 ** scale -1

gap = 2 ** (scale-1)

while True:

  train = 0

  for i in range(n):

    train += max(0, a[i] - aim//f[i])

  if gap == 0:

    if train <= k:

      print(aim)

    else:

      print((aim+1))

    break

  #print(aim,gap,train)

  if train <= k:

    aim -= gap

    gap //= 2

  else:

    aim += gap

    gap //= 2
n, k = list(map(int, input().split()))
a = list(map(int, input().split()))
b = list(map(int, input().split()))
a.sort()
b.sort(reverse=True)
# print(a)
# print(b)
big = 44
stand = 2**big
width = 2 ** (big - 1)
if sum(a) <= k:
    print((0))
else:
    while True:
        tmp = []
        for i in range(n):
            tmp.append(max(0, a[i] - stand // b[i]))
        if width == 0:
            if sum(tmp) <= k:
                print(stand)
            else:
                print((stand + 1))
            break
        if sum(tmp) <= k:
            stand -= width
            width //= 2
        else:
            stand += width
            width //= 2
        # print(stand,tmp)

n, k = list(map(int, input().split()))
a = list(map(int, input().split()))
f = list(map(int, input().split()))
a.sort()
f.sort(reverse=True)
# print(a)
# print(f)
scale = 42
aim = 2**scale - 1
gap = 2 ** (scale - 1)
while True:
    train = 0
    for i in range(n):
        train += max(0, a[i] - aim // f[i])
    if gap == 0:
        if train <= k:
            print(aim)
        else:
            print((aim + 1))
        break
    # print(aim,gap,train)
    if train <= k:
        aim -= gap
        gap //= 2
    else:
        aim += gap
        gap //= 2

-b = list(map(int, input().split())) +f = list(map(int, input().split())) -b.sort(reverse=True) +f.sort(reverse=True) -# print(b) -big = 44 -stand = 2**big -width = 2 ** (big - 1) -if sum(a) <= k: -    print((0)) -else: -    while True: -        tmp = [] -        for i in range(n): -            tmp.append(max(0, a[i] - stand // b[i])) -        if width == 0: -            if sum(tmp) <= k: -                print(stand) -            else: -                print((stand + 1)) -            break -        if sum(tmp) <= k: -            stand -= width -            width //= 2 +# print(f) +scale = 42 +aim = 2**scale - 1 +gap = 2 ** (scale - 1) +while True: +    train = 0 +    for i in range(n): +        train += max(0, a[i] - aim // f[i]) +    if gap == 0: +        if train <= k: +            print(aim) -            stand += width -            width //= 2 -        # print(stand,tmp) +            print((aim + 1)) +        break +    # print(aim,gap,train) +    if train <= k: +        aim -= gap +        gap //= 2 +    else: +        aim += gap +        gap //= 2