s = gets.chomp
t = gets.chomp

s_index = Hash.new{|h,k| h[k]=[]}
s.each_char.with_index do |sn,i|
	s_index[sn] << i
end

def error;puts "-1";exit;end

s_count = 0

(prev_index = s_index[t[0]][0]) || error
t[1..-1].each_char do |tc|
	prev_index = (index = s_index[tc].bsearch {|x| x > prev_index}) ? index : (s_index[tc][0] || error)
	s_count+=1 if !index
end

p (s.length * s_count + prev_index + 1)