local S = io.read("*l")
local SS = S .. S
local T = io.read("*l")

local cur = 0
local ans = 0
local find = string.find
local sub = string.sub
for i=1,#T do
    local c = sub(T, i, i)
    local pos = find(SS, c, cur+1)
    if pos then
        local step = pos - cur
        ans = ans + step
        cur = cur + step
        if cur > #S then
            cur = cur - #S
        end
    else
        print("-1")
        return
    end
end
print(ans)