program problemE
  implicit none
  
  integer, parameter     :: double = selected_real_kind ( 9 )
  integer, parameter     :: i8 = selected_int_kind  ( 18 )
  real ( kind = double ), parameter :: pi = 3.141592653589790_double

  integer ( kind = i8 )                               :: N, K, i, j, tmp, ans, min
  integer ( kind = i8 ), allocatable, dimension ( : ) :: A, F, AF, sA, sF, mxl

  read *, N, K

  allocate ( A   ( 1:N ) )
  allocate ( F   ( 1:N ) )
  allocate ( AF  ( 1:N ) )
  allocate ( sA  ( 1:N ) )
  allocate ( sF  ( 1:N ) )
  allocate ( mxl ( 1:1 ) )
  
  read *, A ( 1:N )
  read *, F ( 1:N )

  sA = sort ( A,  1 )
  sF = sort ( F, -1 )
  print *, A
  print *, F

  AF ( 1:N ) = sA ( 1:N ) * sF ( 1:N )
  
  do i = 1, K
     mxl ( 1:1 ) = maxloc ( AF ( 1:N ) )
     if ( AF ( mxl ( 1 ) )  == 0 ) then
        exit
     end if
     sA ( mxl ( 1 ) ) = sA ( mxl ( 1 ) ) - 1
     AF ( mxl ( 1 ) ) = sA ( mxl ( 1 ) ) * sF ( mxl ( 1 ) )
  end do
 
  ans = maxval ( AF ( 1:N ) )
  print *, ans

  
contains
  
  recursive function sort ( src, pm ) result ( rtn )
    
!!! parameter ==================================================
    
    integer, parameter :: i8 = selected_int_kind  ( 18 )
    integer, intent ( in ) :: pm
    integer ( kind = i8 ),              dimension ( : ) :: src
    integer ( kind = i8 ), allocatable, dimension ( : ) :: rtn
    integer ( kind = i8 ) :: cnt, n
    
!!! allocate ==================================================

    n = size ( src )
    allocate ( rtn ( 1:n ) )
    
!!! ==================================================

    if ( n <= 1 ) then
       rtn = src
    else
       cnt = src ( n / 2 )
       if ( pm == 1 ) then
          rtn = [ sort ( pack ( src, src < cnt ), pm ), &
               & pack ( src, src == cnt ), &
               & sort ( pack ( src, src > cnt ), pm )  ]
       else if ( pm == -1 ) then
          rtn = [ sort ( pack ( src, src > cnt ), pm ), &
               & pack ( src, src == cnt ), &
               & sort ( pack ( src, src < cnt ), pm )  ]
       end if
    end if
    
!!! ==================================================
    return
  end function sort

end program problemE
