a=gets.chop;p [1,2].map{|n|a.bytes.map{|b|eval"1000101021"[b-48]}.sum*n+n+a.size*(3-n)}.min