// dfmt off
T lread(T=long)(){return readln.chomp.to!T;}T[] lreads(T=long)(long n){return iota(n).map!((_)=>lread!T).array;}
T[] aryread(T=long)(){return readln.split.to!(T[]);}void arywrite(T)(T a){a.map!text.join(' ').writeln;}
void scan(L...)(ref L A){auto l=readln.split;foreach(i,T;L){A[i]=l[i].to!T;}}alias sread=()=>readln.chomp();
void dprint(L...)(lazy L A){debug{auto l=new string[](L.length);static foreach(i,a;A)l[i]=a.text;arywrite(l);}}
static immutable MOD=10^^9+7;alias PQueue(T,alias l="b<a")=BinaryHeap!(Array!T,l);import std, core.bitop;
// dfmt on

void main()
{
    auto S = sread();
    auto T = sread();
    auto b = new long[][](26);
    foreach (i, c; S)
        b[c - 'a'] ~= i;
    foreach (c; T)
        if (b[c - 'a'].empty)
        {
            writeln(-1);
            return;
        }
    long ptr;
    long ans;
    foreach (j, c; T)
    {
        long m = long.max;
        foreach (i; b[c - 'a'])
        {
            if (ptr == i)
                m = m.min((j != 0 && T[j - 1] == c) ? S.length : 0);
            if (ptr < i)
                m = m.min(i - ptr);
            if (i < ptr)
                m = m.min(S.length + i - ptr);
        }
        ptr += m;
        ptr %= S.length;
        ans += m;
    }
    writeln(ans + 1);
}
