import Data.List
import Data.Char
import Data.Maybe
import qualified Data.Text as Text
import qualified Data.Text.IO as Text

sol :: Text.Text -> Text.Text -> Int -> Int -> Int -> Int
sol s t p c a
    | tl == c   = a
    | fnd == 0  = (-1)
    | fap == 0  = sol s t (fnd) (c+1) (a + fnd + (sl - p))
    | otherwise = sol s t (p+fap) (c+1) (a + fap)
    where
        sl = Text.length s
        tl = Text.length t
        tc = Text.index t c
        fap = (+) 1 $ fromMaybe (-1) $ Text.findIndex ((==) tc) $ Text.drop (p) s
        fnd = (+) 1 $ fromMaybe (-1) $ Text.findIndex ((==) tc) s

main :: IO ()
main = do
    s <- Text.getLine
    t <- Text.getLine

    print $ sol s t 0 0 0
