import java.util.HashMap
fun main(args: Array<String>) {
    val S = readLine()!!
    val T = readLine()!!
    val SL = S.length
    val TL = T.length
    val M = hashMapOf<Char, MutableList<Int>>()
    S.forEachIndexed{ index, char ->
        val e = M[char]
        if (e == null) M.put(char, mutableListOf(index, index + SL)) else e.addAll(listOf(index, index + SL))
    }
    for ((k, v) in M) v.sort()
    var sn = 0L
    var tn = 0
    while (tn < TL) {
        val e = M[T[tn]]
        if (e == null) {
            println(-1)
            return //exit
        }
        val n = (sn % SL).toInt()
        val b = e.binarySearch(n)
        val p = if (b < 0) e[b.inv()] else e[b]
        sn += (p - n + 1)
        tn += 1
    }
    println(sn)
}
