module app;

import std.algorithm;
import std.array;
import std.bigint;
import std.conv;
import std.stdio;
import std.string;

void main()
{
	auto input = parseInput();
	uint[][26] sinfo;

	foreach (i, c; input.s)
	{
		sinfo[c - 'a'] ~= cast(uint)i;
	}
	
	uint spos = 0;
	BigInt sdashpos = 0;
	
	foreach (c; input.t)
	{
		auto alphabetIndex = c - 'a';
		auto indices = sinfo[alphabetIndex];
		
		if (indices.length == 0)
		{
			writeln("-1");
			return;
		}
		
		auto index = findNextIndex(indices, spos);
		if (spos <= index)
		{
			sdashpos += index - spos + 1;
			spos = index + 1;
		}
		else
		{
			sdashpos += input.s.length - spos + index + 1;
			spos = index + 1;
		}
	}
	
	writefln("%d", sdashpos);
}

uint findNextIndex(uint[] indices, uint spos)
{
	auto temp = indices;
	while (temp.length > 2)
	{
		if (spos <= temp[$/2])
		{
			temp = temp[0..$/2+1];
		}
		else
		{
			temp = temp[$/2..$];
		}
	}
	
	if (temp[$-1] < spos)
		return indices[0];
	else if (spos <= temp[0])
		return temp[0];
	else
		return temp[$-1];
}

unittest
{
	assert(findNextIndex([2, 5, 10, 14, 22], 1) == 2);
	assert(findNextIndex([2, 5, 10, 14, 22], 2) == 2);
	assert(findNextIndex([2, 5, 10, 14, 22], 3) == 5);
	assert(findNextIndex([2, 5, 10, 14, 22], 5) == 5);
	assert(findNextIndex([2, 5, 10, 14, 22], 6) == 10);
	assert(findNextIndex([2, 5, 10, 14, 22], 10) == 10);
	assert(findNextIndex([2, 5, 10, 14, 22], 11) == 14);
	assert(findNextIndex([2, 5, 10, 14, 22], 14) == 14);
	assert(findNextIndex([2, 5, 10, 14, 22], 21) == 22);
	assert(findNextIndex([2, 5, 10, 14, 22], 22) == 22);
	assert(findNextIndex([2, 5, 10, 14, 22], 23) == 2);
}

struct Input
{
	string s;
	string t;
}

Input parseInput()
{
	Input input;
	input.s = readln().strip();
	input.t = readln().strip();
	return input;
}
