import sys

read = sys.stdin.buffer.read

input = sys.stdin.buffer.readline

inputs= sys.stdin.buffer.readlines

#rstrip().decode('utf-8')



#import math

import numpy as np

#import operator

#from heapq import heapify,heappop,heappush

#from math import gcd

#from fractions import gcd

#from collections import deque

#from collections import defaultdict

#from collections import Counter

#from itertools import accumulate

#from itertools import groupby

#from itertools import permutations

#from itertools import combinations

#from scipy.sparse import csr_matrix

#from scipy.sparse.csgraph import floyd_warshall

#from scipy.sparse.csgraph import csgraph_from_dense

#from scipy.sparse.csgraph import dijkstra

#sys.setrecursionlimit(10**7)



#map(int,input().split())



def main():

	NKAF=np.array(read().split(),np.int64)

	N=NKAF[0]

	K=NKAF[1]

	AF=NKAF[2:]

	A,F=np.split(AF,2)

	A.sort()

	F.sort()

	F=F[::-1]

	

	lt=0

	rt=10**12+1

	

	Asum=sum(A)

	

	while rt-lt>1:

		mid=(rt+lt)//2

		if Asum-np.minimum(A,mid//F).sum()<=K:

			rt=mid

		else:

			lt=mid

	print((rt if Asum-K>0 else 0))

	

if __name__ == '__main__':

	main()
import sys

read = sys.stdin.buffer.read

input = sys.stdin.buffer.readline

inputs= sys.stdin.buffer.readlines

#rstrip().decode('utf-8')



#import math

import numpy as np

#import operator

#from heapq import heapify,heappop,heappush

#from math import gcd

#from fractions import gcd

#from collections import deque

#from collections import defaultdict

#from collections import Counter

#from itertools import accumulate

#from itertools import groupby

#from itertools import permutations

#from itertools import combinations

#from scipy.sparse import csr_matrix

#from scipy.sparse.csgraph import floyd_warshall

#from scipy.sparse.csgraph import csgraph_from_dense

#from scipy.sparse.csgraph import dijkstra

#sys.setrecursionlimit(10**7)



#map(int,input().split())



def main():

	NKAF=np.array(read().split(),np.int64)

	N=NKAF[0]

	K=NKAF[1]

	AF=NKAF[2:]

	A,F=np.split(AF,2)

	A.sort()

	F.sort()

	F=F[::-1]

	

	lt=0

	rt=10**12+1

	

	Asum=A.sum()

	

	while rt-lt>1:

		mid=(rt+lt)//2

		if Asum-np.minimum(A,mid//F).sum()<=K:

			rt=mid

		else:

			lt=mid

	print((rt if Asum-K>0 else 0))

	

if __name__ == '__main__':

	main()
import sys

read = sys.stdin.buffer.read
input = sys.stdin.buffer.readline
inputs = sys.stdin.buffer.readlines
# rstrip().decode('utf-8')
# import math
import numpy as np

# import operator
# from heapq import heapify,heappop,heappush
# from math import gcd
# from fractions import gcd
# from collections import deque
# from collections import defaultdict
# from collections import Counter
# from itertools import accumulate
# from itertools import groupby
# from itertools import permutations
# from itertools import combinations
# from scipy.sparse import csr_matrix
# from scipy.sparse.csgraph import floyd_warshall
# from scipy.sparse.csgraph import csgraph_from_dense
# from scipy.sparse.csgraph import dijkstra
# sys.setrecursionlimit(10**7)
# map(int,input().split())
def main():
    NKAF = np.array(read().split(), np.int64)
    N = NKAF[0]
    K = NKAF[1]
    AF = NKAF[2:]
    A, F = np.split(AF, 2)
    A.sort()
    F.sort()
    F = F[::-1]
    lt = 0
    rt = 10**12 + 1
    Asum = sum(A)
    while rt - lt > 1:
        mid = (rt + lt) // 2
        if Asum - np.minimum(A, mid // F).sum() <= K:
            rt = mid
        else:
            lt = mid
    print((rt if Asum - K > 0 else 0))


if __name__ == "__main__":
    main()

import sys

read = sys.stdin.buffer.read
input = sys.stdin.buffer.readline
inputs = sys.stdin.buffer.readlines
# rstrip().decode('utf-8')
# import math
import numpy as np

# import operator
# from heapq import heapify,heappop,heappush
# from math import gcd
# from fractions import gcd
# from collections import deque
# from collections import defaultdict
# from collections import Counter
# from itertools import accumulate
# from itertools import groupby
# from itertools import permutations
# from itertools import combinations
# from scipy.sparse import csr_matrix
# from scipy.sparse.csgraph import floyd_warshall
# from scipy.sparse.csgraph import csgraph_from_dense
# from scipy.sparse.csgraph import dijkstra
# sys.setrecursionlimit(10**7)
# map(int,input().split())
def main():
    NKAF = np.array(read().split(), np.int64)
    N = NKAF[0]
    K = NKAF[1]
    AF = NKAF[2:]
    A, F = np.split(AF, 2)
    A.sort()
    F.sort()
    F = F[::-1]
    lt = 0
    rt = 10**12 + 1
    Asum = A.sum()
    while rt - lt > 1:
        mid = (rt + lt) // 2
        if Asum - np.minimum(A, mid // F).sum() <= K:
            rt = mid
        else:
            lt = mid
    print((rt if Asum - K > 0 else 0))


if __name__ == "__main__":
    main()

-    Asum = sum(A) +    Asum = A.sum()