//use itertools::Itertools;
use std::cmp;
use std::collections::BTreeMap;
use std::collections::BTreeSet;
use std::collections::BinaryHeap;
use std::collections::HashMap;
use std::collections::HashSet;
use std::collections::VecDeque;
use std::io::Read;
use std::usize::MAX;

macro_rules! input {(source = $s:expr, $($r:tt)*) => {let mut iter = $s.split_whitespace();let mut next = || { iter.next().unwrap() };input_inner!{next, $($r)*}};($($r:tt)*) => {let stdin = std::io::stdin();let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));let mut next = move || -> String{bytes.by_ref().map(|r|r.unwrap() as char).skip_while(|c|c.is_whitespace()).take_while(|c|!c.is_whitespace()).collect()};input_inner!{next, $($r)*}};}
macro_rules! input_inner {($next:expr) => {};($next:expr, ) => {};($next:expr, $var:ident : $t:tt $($r:tt)*) => {let $var = read_value!($next, $t);input_inner!{$next $($r)*}};}
macro_rules! read_value {($next:expr, ( $($t:tt),* )) => {( $(read_value!($next, $t)),* )};($next:expr, [ $t:tt ; $len:expr ]) => {(0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()};($next:expr, chars) => {read_value!($next, String).chars().collect::<Vec<char>>()};($next:expr, usize1) => {read_value!($next, usize) - 1};($next:expr, [ $t:tt ]) => {{let len = read_value!($next, usize);(0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()}};($next:expr, $t:ty) => {$next().parse::<$t>().expect("Parse error")};}

fn solve() {
    input! {
        s: chars,
        t: chars
    }

    let mut s_char_map: HashMap<char, Vec<usize>> = HashMap::new();
    for i in 0..s.len() {
        s_char_map.entry(s[i]).or_insert_with(Vec::new).push(i);
    }

    //println!("{:?}", s_char_map);

    let mut ans = 0;
    let mut t_char_count: HashMap<char, usize> = HashMap::new();
    let mut not_exists = false;
    let mut current_s_index = -1;
    for i in 0..t.len() {
        let count = t_char_count.entry(t[i]).or_insert(0);
        *count += 1;

        if let Some(s_chars) = s_char_map.get(&t[i]) {
            let mut reset = true;
            if *count > s_chars.len() {
                reset = true;
            } else {
                for j in *count - 1..s_chars.len() {
                    if s_chars[j] as i64 > current_s_index {
                        current_s_index = s_chars[j] as i64;

                        reset = false;
                        break;
                    }
                }
            }

            if reset {
                t_char_count.clear();
                ans += s.len();
                current_s_index = s_chars[0] as i64;
            }

            //println!("{} {} {}", t[i], current_s_index, ans / s.len());

            if i == t.len() - 1 {
                ans += current_s_index as usize + 1;
            }
        } else {
            not_exists = true;
        }

        if not_exists {
            break;
        }
    }

    if not_exists {
        println!("-1");
    } else {
        println!("{}", ans);
    }
}

fn main() {
    let thd = std::thread::Builder::new().stack_size(104_857_600);
    thd.spawn(|| solve()).unwrap().join().unwrap();

    /*
    // 入力を一括で読み込む場合
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    let mut input = buf.split_whitespace();

    // inputに対しnext()で読み込んでいく
    let q: usize = input.next().unwrap().parse().unwrap();
    */
}

const LARGE_PRIME: u64 = 1_000_000_007;

// @〜でsnippet


Measured memory_bytes: 3016