import Data.Char
import Data.List
import qualified Data.Vector as V
import qualified Data.Vector.Mutable as VM
import Control.Monad

main = do
    ss <- zipWith (\i c -> (ord c - ord 'a', i)) [1..] <$> getLine
    ts <- map (\c -> ord c - ord 'a') <$> getLine
    let abc = V.create $ do
            vec <- VM.replicate 26 []
            forM_ (reverse ss) $ \(c,i) -> do
                VM.modify vec (i:) c
            return vec

    let f Nothing _ = Nothing
        f (Just (k,i)) c = case jdx of
                            Just j -> if j > i then (Just (k,j)) else (Just (k+1,j))                       
                            _ -> Nothing
                where jdx | null idx = Nothing
                          | otherwise = let a = dropWhile (<= i) idx in if null a then Just (head idx) else Just (head a)
                        where idx = abc V.! c
    let ans = case (foldl' f (Just (0,0)) ts) of
                Nothing -> -1
                Just (k,i) -> (length ss) * k + i
    print ans