s = gets.chomp
t = gets.chomp

index = t.split("").map {|c| s.index c}

if index.include? nil
  puts -1
  exit
end

length = s.length
unit = 0
target_index = 0
ts = s.dup
t.split("").each do |tp|
  loop do
    tsi = ts.index tp
    if tsi.nil?
      ts = s.dup
      unit += 1
      target_index = 0
      next
    end
    ts.slice!(0, tsi + 1)
    target_index += tsi + 1
    break
  end
end

puts "#{unit * length + target_index}"
