a=gets.chop;p [1,2].map{|n|eval(a.tr("0-9","1000101021").chars*?+)*n+n+a.size*(3-n)}.min