void main()
{
    string s = readln.chomp;
    string t = readln.chomp;

    long[][] alpha = new long[][](26);
    foreach (i, x; s)
    {
        alpha[x-'a'] ~= i + 1;
    }

    long n = s.length.to!long;
    long cnt;
    long index;
    foreach (x; t)
    {
        auto a = alpha[x-'a'].assumeSorted;

        if (a.empty)
        {
            cnt = -1;
            break;
        }

        auto l = a.upperBound(index);
        if (l.empty)
        {
            ++cnt;
            index = a[0];
        }
        else
        {
            index = l[0];
        }
    }

    writeln(cnt != -1 ? cnt * n + index: cnt);
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.container;
import std.typecons;
import std.ascii;
import std.uni;