import java.io.BufferedReader
import java.io.InputStreamReader
import java.io.PrintWriter

val br = BufferedReader(InputStreamReader(System.`in`))
val out = PrintWriter(System.out)

fun main() {
    br.use { out.use {
        solve()
        out.flush()
    } }
}

fun solve() {
    val s = br.readLine()!!
    val t = br.readLine()!!

    val sSet = s.toSet()
    if (sSet.union(t.toSet()).size > sSet.size) {
        out.println(-1)
        return
    }

    val charOccurenceList = Array('z' - 'a' + 1) { mutableListOf<Int>() }
    for ((i, c) in s.withIndex()) {
        charOccurenceList[c - 'a'].add(i + 1)
    }

    var ans = 0L
    var preIndex = 0
    for (c in t) {
        var left = -1
        var right = charOccurenceList[c - 'a'].size
        while (right - left > 1) {
            val mid = (left + right) / 2
            if (preIndex < charOccurenceList[c - 'a'][mid]) {
                right = mid
            } else {
                left = mid
            }
        }

        if (right !in charOccurenceList[c - 'a'].indices) {
            val nextIndex = charOccurenceList[c - 'a'][0]
            ans += s.length - preIndex + nextIndex
            preIndex = nextIndex
        } else {
            val nextIndex = charOccurenceList[c - 'a'][right]
            ans += nextIndex - preIndex
            preIndex = nextIndex
        }
    }

    out.println(ans)
}

fun readInteger() = Integer.parseInt(br.readLine())
fun readLong() = java.lang.Long.parseLong(br.readLine())
fun readStringList() = br.readLine()!!.split(' ')
fun readIntegerList() = readStringList().map(Integer::parseInt)
fun readLongList() = readStringList().map(java.lang.Long::parseLong)
fun readDoubleList() = readStringList().map(java.lang.Double::parseDouble)
