module app;

import std.algorithm;
import std.array;
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;
	uint sdashpos = 0;
	
	foreach (c; input.t)
	{
		auto alphabetIndex = c - 'a';
		auto indices = sinfo[alphabetIndex];
		
		if (indices.length == 0)
		{
			writeln("-1");
			return;
		}
		
		bool found = false;
		foreach (index; indices)
		{
			if (spos <= index)
			{
				found = true;
				sdashpos += index - spos + 1;
				spos = index + 1;
				break;
			}
		}
		
		if (!found)
		{
			auto index = indices[0];
			sdashpos += input.s.length - spos + index + 1;
			spos = index + 1;
		}
	}
	
	writefln("%d", sdashpos);
}

struct Input
{
	string s;
	string t;
}

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