import Data.List
import Control.Monad
f a m r = if m==0 then r else if m-((last.minimum) a)<0 then r+((head.minimum)a*m) else f [x|x<-a,x/=minimum a] (m-((last.minimum) a)) (r+(product.minimum) a)
main=do
 [n,m]<-map read.words<$>getLine
 a<-map (map read.words)<$>replicateM n getLine
 print$f a m 0