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, allocatable, dimension ( : ) :: mxl
  integer ( kind = i8 )                               :: N, K, i, j, tmp, ans, min
  integer ( kind = i8 ), allocatable, dimension ( : ) :: A, F, AF, sA, sF 

  read *, N, K

  allocate ( mxl ( 1:1 ) )
  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 ( N, A, sA, F, sF )
  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_i8
     AF ( mxl ( 1 ) ) = sA ( mxl ( 1 ) ) * sF ( mxl ( 1 ) ) 
  end do
  AF ( 1:N ) = sA ( 1:N ) * sF ( 1:N )
 
  ans = maxval ( AF ( 1:N ) )
  print *, ans

  
contains
  
  subroutine sort ( n, lagsrc, lagrtn, smasrc, smartn )
    implicit none
    
!!! parameter ==================================================
    
    integer, parameter :: i8 = selected_int_kind  ( 18 )
    integer ( kind = i8 ) :: i, max, min, imax, imin
    integer ( kind = i8 ),                               intent ( in )  :: n
    integer ( kind = i8 ), allocatable, dimension ( : ), intent ( in )  :: lagsrc, smasrc
    integer ( kind = i8 ), allocatable, dimension ( : ), intent ( out ) :: lagrtn, smartn
    integer ( kind = i8 ), allocatable, dimension ( : )                 :: lagtmp, smatmp

    
!!! allocate ==================================================
    
    allocate ( lagrtn ( n ) )
    allocate ( lagtmp ( n ) )
    allocate ( smartn ( n ) )
    allocate ( smatmp ( n ) )
    
    max  = maxval ( lagsrc ( 1:n ) )
    imax = maxval ( lagsrc ( 1:n ) )
    min  = minval ( lagsrc ( 1:n ) )
    imin = minval ( lagsrc ( 1:n ) )


!!! sort ==================================================
    
    max  = maxval ( lagsrc ( 1:n ) )
    lagtmp = pack ( lagsrc, lagsrc == max )
    lagrtn = [ lagtmp ( : ) ]
    
    min  = minval ( smasrc ( 1:n ) )
    smatmp = pack ( smasrc, smasrc == min )    
    smartn = [ smatmp ( : ) ]
    
    do i = imin, imax
       max = max - 1
       lagtmp = pack ( lagsrc, lagsrc == max )
       lagrtn = [ lagrtn, lagtmp ]
       
       min = min + 1
       smatmp = pack ( smasrc, smasrc == min )
       smartn = [ smartn, smatmp ]
    end do
       
    
!!! ==================================================
    
  end subroutine sort
  

end program problemE
