// 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 k = () {
            long ok = 0;
            long ng = b[c - 'a'].length;
            while (1 < ng - ok)
            {
                long m = (ok + ng) / 2;
                if (b[c - 'a'][m] <= ptr)
                    ok = m;
                else
                    ng = m;
            }
            return ok;
        }();
        long m = long.max;
        foreach (i; [
                b[c - 'a'][k], b[c - 'a'][(k + 1) % $], b[c - 'a'][($ + k - 1) % $]
            ])
        {
            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);
}
