import java.util.*

fun main(args: Array<String>) {
    val s = readLine()!!
    val t = readLine()!!
    val map = HashMap<Char, ArrayList<Long>>()
    s.toCharArray().forEachIndexed { index, c ->
        val i = index.toLong()
        if (map[c] == null) {
            map[c] = arrayListOf(i, i + s.length)
        } else {
            with(map[c]!!) {
                add(i)
                add(i + s.length)
            }
        }
    }
    map.values.forEach { it.sort() }

    var ans = 0L
    t.forEach { c ->
        if (map[c] == null) {
            println("-1")
            return
        }
        val list = map[c]!!
        var b = list
                .binarySearch(ans % s.length)
                .let { if (it < 0) it.inv() else it }
        val p = list[b]
        ans += (p - ans % s.length + 1)
    }
    println(ans)
}