import java.util.Collections

fun main(args: Array<String>) {
    val s = readInputLine().toCharArray()
    val t = readInputLine().toCharArray()
    
    val sSize = s.size.toLong()

    val indices = Array(26, {mutableListOf<Long>()})
    
    for ((i, sc) in s.withIndex()) {
        indices[sc - 'a'].add(i.toLong())
    }
    
    for (tc in t) {
        if (indices[tc - 'a'].isEmpty()) {
            println(-1)
            return
        }
    }
    
    var ans = 0L
    
    var lastFound = -1L
    
    for (tc in t) {
        val indicesIndex = upperBound(indices[tc - 'a'], lastFound)
        val nextIndex = if (indicesIndex >= indices[tc - 'a'].size) indices[tc - 'a'].first() else indices[tc - 'a'][indicesIndex]

        ans += if (nextIndex > lastFound) nextIndex - lastFound else sSize - lastFound + nextIndex

        lastFound = nextIndex
    }

    println(ans)
}

fun readInputLine(): String {
    return readLine()!!
}

fun <T: Comparable<T>> upperBound(list: List<T>, value: T): Int {
    return Collections.binarySearch(list, value, {x, y -> if (x > y) 1 else -1}).inv()
}
