import std.stdio, std.conv, std.string, std.array, std.range, std.algorithm, std.container;
import std.math, std.random, std.bigint, std.datetime, std.format;
void main(string[] args){ if(args.length > 1) if(args[1] == "-debug") DEBUG = 1; solve(); }
void log()(){ writeln(""); } void log(T, A ...)(T t, lazy A a){ if(DEBUG) write(t, " "), log(a); } bool DEBUG = 0; 
string read(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }
// ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- //

void solve(){
	string s = readln.chomp;
	string t = readln.chomp;
	
	int n = s.length;
	int m = t.length;
	
	int[][] xf = new int[][](26, n);
	// xf[k][i]: position where character k will be found after position i
	// (-1 if impossible)
	foreach(k; 0 .. 26) foreach(i; 0 .. n) xf[k][i] = -1;
	log("xf:", xf);
	
	int[][] pos;
	foreach(k; 0 .. 26){
		int[] q = [];
		pos ~= q;
	}
	foreach(i, c; s){
		int k = (c - 'a').to!int;
		pos[k] ~= i;
	}
	log("pos:", pos);
	
	foreach(k; 0 .. 26){
		log("k:", k, "pos[k]:", pos[k], "length:", pos[k].length);
		if(pos[k].length == 0){
			foreach(i; 0 .. n) xf[k][i] = -1;
		}
		else{
			int ix = 0;
			foreach(i; 0 .. n){
				if(i < pos[k][ix]) xf[k][i] = pos[k][ix];
				else if(ix < pos[k].length - 1){
					ix += 1;
					xf[k][i] = pos[k][ix];
				}
				else xf[k][i] = pos[k][0];
				log("k:", k, "i:", i, "ix:", ix, "xf[k]:", xf[k]);
			}
		}
	}
	log("xf:", xf);
	
	long ans = 1;
	int x = 0;
	foreach(j, c; t){
		int k = (c - 'a').to!int;
		log("ans:", ans, "x:", x, "j:", j, "c:", "" ~ c, "xf[k][x]:", xf[k][x]);
		if(xf[k][x] < 0){
			"-1".writeln;
			return;
		}
		else{
			if(xf[k][x] <= x){
				ans += (n + xf[k][x]) - x;
				x = xf[k][x];
			}
			else{
				ans += xf[k][x] - x;
				x = xf[k][x];
			}
		}
	}
	
	ans.writeln;
	
}
