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 

  read *, N, K

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

  call sort ( A, N, sA,  1 )
  call sort ( F, N, sF, -1 )

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

  
contains
  
  subroutine sort ( src, n, rtn, pm )
    implicit none
    
!!! parameter ==================================================
    
    integer, parameter :: i8 = selected_int_kind  ( 18 )
    integer, intent ( in ) :: pm
    integer ( kind = i8 ),                               intent ( in )  :: n
    integer ( kind = i8 ), allocatable, dimension ( : ), intent ( in )  :: src
    integer ( kind = i8 ), allocatable, dimension ( : ), intent ( out ) :: rtn
    integer ( kind = i8 ), allocatable, dimension ( : ) :: tmp
    integer ( kind = i8 ) :: i, max, min, imax, imin
    
!!! allocate ==================================================
    
    allocate ( rtn ( n ) )
    allocate ( tmp ( n ) )
    
    imax = maxval ( src ( 1:n ) )
    imin = minval ( src ( 1:n ) )
    
!!! from maxmum ==================================================
    
    if ( pm == 1 ) then
       max  = maxval ( src ( 1:n ) )
       tmp = pack ( src, src == max )
       rtn = [ tmp ( : ) ]
       do i = imin, imax
          max = max - 1
          tmp = pack ( src, src == max )
          rtn = [ rtn, tmp ]
       end do
    end if
    
!!! from minmum ==================================================
    
    if ( pm == -1 ) then
       min  = minval ( src ( 1:n ) )
       tmp = pack ( src, src == min )
       rtn = [ tmp ( : ) ]
       do i = imin, imax
          min = min + 1
          tmp = pack ( src, src == min )
          rtn = [ rtn, tmp ]
       end do
    end if
    
!!! ==================================================
    
  end subroutine sort
  

end program problemE
