import std;
import core.bitop;

ulong MAX = 100_100, MOD = 1_000_000_007, INF = 1_000_000_000_000;
alias sread = () => readln.chomp();
alias lread(T = long) = () => readln.chomp.to!(T);
alias aryread(T = long) = () => readln.split.to!(T[]);
alias Pair = Tuple!(long, "x", long, "c");
alias PQueue(T, alias less = "a>b") = BinaryHeap!(Array!T, less);

void main()
{
    auto s = sread();
    auto t = sread();
    auto nexts = new long[][](s.length, 26);
    foreach (ref e; nexts)
        e[] = INF;

    foreach_reverse (i; iota(2 * s.length))
    {
        foreach (j; iota(26))
        {
            if (s[(i + 1) % s.length] == 'a' + j)
                nexts[i % s.length][j] = 1;
            else
                nexts[i % s.length][j] = nexts[(i + 1) % s.length][j] + 1;
        }
    }

    long idx = s.countUntil(t[0]);
    foreach (e; t[1 .. $])
    {
        if (idx < 0)
            break;
            
        if (nexts[idx % s.length][e - 'a'] <= s.length)
            idx += nexts[idx % s.length][e - 'a'];
        else
            idx = -1;
    }

    writeln(idx >= 0 ? idx + 1 : idx);
}

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}
