import qualified Data.Set as S

main = do
  s <- getLine
  t <- getLine
  let ans = compute s t
  print ans

compute :: String -> String -> Int
compute s t
  | not (S.isSubsetOf ts ss) = -1
  | True = loop 0 t (cycle s)
  where
    ss = S.fromList s
    ts = S.fromList t

loop c [] _ = c
loop c tts@(t:ts) (s:ss)
  | t == s = loop (succ c) ts ss
  | True   = loop (succ c) tts ss