import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

size_t[][26] D;

void main()
{
    auto s = readln.chomp.to!(char[]);
    auto t = readln.chomp.to!(char[]);

    foreach (i, c; s) {
        D[c - 'a'] ~= i;
    }

    ulong cnt;
    size_t p;
    bool first = true;
    foreach (c; t) {
        auto d = D[c - 'a'];

        if (d.empty) {
            writeln(-1);
            return;
        }

        if (first) {
            first = false;
            if (d[0] == 0) {
                continue;
            }
        }

        if (d[$-1] <= p) {
            p = d[0];
            ++cnt;
            continue;
        } else if (d[0] > p) {
            p = d[0];
            continue;
        }

        size_t l, r = d.length-1;
        while (l+1 < r) {
            auto m = (l+r)/2;
            if (d[m] <= p) {
                l = m;
            } else {
                r = m;
            }
        }
        p = d[r];
    }
    writeln(s.length * cnt + p + 1);
}