import std.algorithm;
import std.bigint;
import std.container;
import std.conv;
import std.functional;
import std.math;
import std.meta;
import std.random;
import std.range;
import std.stdio;
import std.string;
import std.traits;
import std.typecons;


long solve(string s, string t){
    auto conn = new long[26][](s.length + 1);
    long[26] a;

    foreach (i; 0 .. 26)
        a[i] = -1;

    foreach (_; 0 .. 2) {
        foreach_reverse (i, c; s) {
            conn[i + 1] = a;
            a[c - 'a'] = i + 1;
        }
        conn[0] = a;
    }

    long pi, i;
    long ans;
    immutable long slen = s.length.to!long;
    foreach (c; t) {
        i = conn[pi.to!size_t][c - 'a'];
        if (i < 0)
            return ans = -1;

        if ((i - pi) % slen == 0)
            ans += slen;
        else
            ans += (slen + i - pi) % slen;

        pi = i;
    }

    return ans;
}


void main(){
    auto input = stdin.byLine.map!split.joiner;

    string s;
    s = input.front.to!string;
    input.popFront;

    string t;
    t = input.front.to!string;
    input.popFront;

    static if (is(ReturnType!solve == void))
        solve(s, t);
    else
        solve(s, t).writeln;
}
