import Data.Char
import Data.List
import qualified Data.IntMap.Strict as M

main = do
    ss <- zipWith (\i c -> (ord c - ord 'a', i)) [1..] <$> getLine
    ts <- map (\c -> ord c - ord 'a') <$> getLine
    let abc = foldr (\(c,i) m -> M.insertWith (++) c [i] m) M.empty ss
    let f Nothing _ = Nothing
        f (Just (k,i)) c = case idx of
                            Just j -> if j > i then (Just (k,j)) else (Just (k+1,j))                       
                            _ -> Nothing
                where idx = M.lookup c abc >>= \ks -> safehead ((dropWhile (<= i) ks) ++ ks)
                      safehead ks = if null ks then Nothing else Just (head ks)
    let ans = case (foldl' f (Just (0,0)) ts) of
                Nothing -> -1
                Just (k,i) -> (length ss) * k + i
    print ans