#[allow(unused_macros)]
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)*}
    };
}

#[allow(unused_macros)]
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)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
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, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

use std::cmp::Ordering;
trait BinarySearch<T> {
    fn upper_bound(&self, value: &T) -> usize;
    fn lower_bound(&self, value: &T) -> usize;
}

impl<T: Ord> BinarySearch<T> for [T] {
    fn upper_bound(&self, value: &T) -> usize {
        let (mut l, mut r) = (0, self.len());
        while l < r {
            let mid = (l + r) / 2;
            match self[mid].cmp(value) {
                Ordering::Greater => {
                    r = mid;
                }
                Ordering::Equal | Ordering::Less => {
                    l = mid + 1;
                }
            };
        }
        r
    }

    fn lower_bound(&self, value: &T) -> usize {
        let (mut l, mut r) = (0, self.len());
        while l < r {
            let mid = (l + r) / 2;
            match self[mid].cmp(&value) {
                Ordering::Equal | Ordering::Greater => {
                    r = mid;
                }
                Ordering::Less => {
                    l = mid + 1;
                }
            };
        }
        r
    }
}

fn main() {
    input! {
        s: chars, t: chars
    }
    let mut pairs = vec![];
    for i in 0..s.len() {
        pairs.push((s[i], i));
    }
    pairs.sort();
    let mut pos = 0;
    let mut count = 0;
    for &ti in &t {
        let i = pairs.lower_bound(&(ti, pos));
        // println!("{}, {}, {}", ti, pos, i);
        if i >= pairs.len() || pairs[i].0 != ti {
            // println!("hoge");
            count += 1;
            let j = pairs.lower_bound(&(ti, 0));
            if j >= pairs.len() || pairs[j].0 != ti {
                println!("-1");
                return;
            }
            pos = pairs[j].1 + 1;
        } else {
            if pairs[i].1 < pos {
                // println!("fuga");
                count += 1;
            }
            pos = pairs[i].1 + 1;
        }
    }
    println!("{}", count * s.len() + pos);
}


Measured memory_bytes: 8444