local mfl = math.floor

local function comp(a, b)
  return a < b
end

local function lower_bound(ary, x)
  local num = #ary
  if num == 0 then return 1 end
  if not comp(ary[1], x) then return 1 end
  if comp(ary[num], x) then return num + 1 end
  local min, max = 1, num
  while 1 < max - min do
    local mid = mfl((min + max) / 2)
    if comp(ary[mid], x) then
      min = mid
    else
      max = mid
    end
  end
  return max
end
local function upper_bound(ary, x)
  local num = #ary
  if num == 0 then return 1 end
  if comp(x, ary[1]) then return 1 end
  if not comp(x, ary[num]) then return num + 1 end
  local min, max = 1, num
  while 1 < max - min do
    local mid = mfl((min + max) / 2)
    if not comp(x, ary[mid]) then
      min = mid
    else
      max = mid
    end
  end
  return max
end

local s = io.read()
local t = io.read()
local n = #s
local m = #t
local s_tbl = {}
local sstr = ""
for i = 1, n do
  sstr = s:sub(i, i)
  if not s_tbl[sstr] then s_tbl[sstr] = {} end
  table.insert(s_tbl[sstr], i)
end

local curpos = 0
local loop = 0
local isok = true
for i = 1, m do
  sstr = t:sub(i, i)
  if not s_tbl[sstr] then
    isok = false
    break
  else
    local bnd = upper_bound(s_tbl[sstr], curpos)
    if #s_tbl[sstr] < bnd then
      loop = loop + 1
      curpos= s_tbl[sstr][1]
    else
      curpos = s_tbl[sstr][bnd]
    end
  end
end

if isok then
print(loop * n + curpos)
else
  print(-1)
end
