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

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

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

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

        if (a[$-1] < index)
        {
            cnt += n - index + a[0];
            index = a[0];
        }
        else
        {
            long l, r = a.length.to!long - 1;
            while (l + 1 < r)
            {
                long m = (l + r) / 2;
                if (a[m] <= index)
                {
                    l = m;
                }
                else
                {
                    r = m;
                }
            }

            cnt += a[l] - index;

            index = a[l];
        }
    }

    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;