program main
  implicit none
  integer(8) i,ns,nt,judge,ans,j,c2
  character(10**5) s,t
  character c1
  read(*, *)s, t
  ns = len(trim(s))
  nt = len(trim(t))
  ans = 1
  c2 = 1
  judge = 1
  do i = 1,nt
    c1 = t(i:i)
    do j = 1,ns+1
      ans = ans + 1
      c2 = c2 + 1
      if (c2 == ns + 1) then
        c2 = 1
      end if 
      if (j == ns + 1) then
        judge = 0
        exit
      elseif (s(c2:c2) == c1) then
        exit
      end if
    end do
  end do
  !read(*, *) (L(i), i = 1,N)
  if (judge == 0) then
    write(*, *) -1
  else
    write(*, *) ans
  end if
end program main
