import core.bitop, std.bitmanip;
import core.checkedint;
import std.algorithm, std.functional;
import std.array, std.container;
import std.bigint;
import std.conv;
import std.math, std.numeric;
import std.range, std.range.interfaces;
import std.stdio, std.string;
import std.typecons;

void main()
{
    auto s = readln.chomp;
    auto t = readln.chomp;
    
    auto input = new int[][] (300);
    
    foreach (i, e; s) {
        input[e] ~= (i+1).to!int;
    }
    
    debug { input.writeln; }
    
    auto pos = input.map!assumeSorted;
    
    long ans = 0;
    int cpos = 0;
    foreach (e; t) {
        if (pos[e].empty()) {
            writeln(-1);
            return;
        }
        
        auto r = pos[e].upperBound(cpos);
        if (r.empty()) {
            ans += s.length - cpos;
            cpos = 0;
            r = pos[e].upperBound(0);
        }
        
        auto nxt = r[0];
        ans += nxt - cpos;
        
        debug { writeln(e, ' ', ans, ' ', nxt); }
        
        cpos = nxt;
    }
    
    ans.writeln;
}