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

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

    long n = s.length.to!long;
    long cnt = 1;
    long index;
    foreach (x; t)
    {
        bool ok;
        foreach (y; alpha[x-'a'])
        {
            if (y > index)
            {
                ok = true;
                cnt += y - index;
                index = y % n;
                break;
            }
        }

        if (!ok)
        {
            cnt = -1;
            break;
        }
    }

    cnt.writeln;
}

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;