#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <algorithm>
#include <iomanip>
#include <math.h>
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;
using vl = vector<ll>;
using vll = vector<vl>;
#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define REPR(i,n) for(int i=n-1; i>=(int)(0); i--)
#define FOR(i,a,b) for(int i=(int)(a); i<(int)(b); i++)
#define FORR(i,a,b) for(int i=(int)(b)-1; i>=(int)(a); i--)
#define CHMIN(a,b) (a)=min((a),(b))
#define CHMAX(a,b) (a)=max((a),(b))
#define ALL(v) (v).begin(),(v).end()
//**関数リスト**//
int ctoi(char c) {
	switch (c) {
	case '0': return 0;
	case '1': return 1;
	case '2': return 2;
	case '3': return 3;
	case '4': return 4;
	case '5': return 5;
	case '6': return 6;
	case '7': return 7;
	case '8': return 8;
	case '9': return 9;
	default: return 0;
	}
}
bool pairCompare(const pll firstElof, pll secondElof)
{
	return firstElof.second < secondElof.second;
}
ll nod(ll F) {
	ll keta = 1;
	while (F / 10 > 0) {
		keta++;
		F /= 10;
	}
	return keta;
}
ll gcd(ll x, ll y) {
	ll r;
	if (x < y) {
		swap(x, y);
	}
	while (y > 0) {
		r = x % y;
		x = y;
		y = r;
	}
	return x;
}
ll lcm(ll x, ll y) {
	return x * y / gcd(x, y);
}
ll isPrime(ll x) {
	ll i;
	if (x < 2) {
		return 0;
	}
	else if (x == 2) {
		return 1;
	}
	else if (x % 2 == 0) {
		return 0;
	}
	else {
		for (i = 3; i * i <= x; i += 2) {
			if (x % 1 == 0) {
				return 0;
			}
		}
		return 1;
	}
}
void eratos(vl isPrime) {
	//(注)isPrimeのサイズはN+1にする！実際にはmain内に配置して使用
	ll i, j;
	REP(i, isPrime.size()) {
		isPrime[i] = 1;
	}
	isPrime[0] = 0; isPrime[1] = 0;
	for (i = 2; i * i <= isPrime.size() - 1; i++) {
		if (isPrime[i] == 1) {
			j = i * 2;
			while (j <= isPrime.size() - 1) {
				isPrime[j] = 0;
				j = j + i;
			}
		}
	}
}
ll modinv(ll a, ll m) {
	ll b = m, u = 1, v = 0;
	while (b) {
		ll t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
void bitSearch(ll n) {
	//実際にはコピーして中身を改変して使う
	ll i;
	REP(i, pow(2, n)) {
		ll p = i;
		REP(i, n) {
			cout << p % 2;
			p /= 2;
		}
		cout << endl;
	}
}

void bfs(ll now) {
	//中身は毎回書き換えて使用
	queue<ll> Q;
	Q.push(now);
	ll u;
	while (!Q.empty()) {
		u = Q.front();
		Q.pop();
		//ll v=;
		//Q.push(v);
	}
}
//**定義場所**//
ll i, j, k, l, m, n;
ll N, M, K, H, W;
ll MOD = 1000000007;
ll ans = 0;
//***********//

int main() {
	string S, T;
	cin >> S >> T;
	M = S.size();
	N = T.size();
	vll P(26);
	for (i = 0; i < M; i++) {
		ll b = 0;
		if (S[i] == 'a') { P[b].push_back(i); }b++;
		if (S[i] == 'b') { P[b].push_back(i); }b++;
		if (S[i] == 'c') { P[b].push_back(i); }b++;
		if (S[i] == 'd') { P[b].push_back(i); }b++;
		if (S[i] == 'e') { P[b].push_back(i); }b++;
		if (S[i] == 'f') { P[b].push_back(i); }b++;
		if (S[i] == 'g') { P[b].push_back(i); }b++;
		if (S[i] == 'h') { P[b].push_back(i); }b++;
		if (S[i] == 'i') { P[b].push_back(i); }b++;
		if (S[i] == 'j') { P[b].push_back(i); }b++;
		if (S[i] == 'k') { P[b].push_back(i); }b++;
		if (S[i] == 'l') { P[b].push_back(i); }b++;
		if (S[i] == 'm') { P[b].push_back(i); }b++;
		if (S[i] == 'n') { P[b].push_back(i); }b++;
		if (S[i] == 'o') { P[b].push_back(i); }b++;
		if (S[i] == 'p') { P[b].push_back(i); }b++;
		if (S[i] == 'q') { P[b].push_back(i); }b++;
		if (S[i] == 'r') { P[b].push_back(i); }b++;
		if (S[i] == 's') { P[b].push_back(i); }b++;
		if (S[i] == 't') { P[b].push_back(i); }b++;
		if (S[i] == 'u') { P[b].push_back(i); }b++;
		if (S[i] == 'v') { P[b].push_back(i); }b++;
		if (S[i] == 'w') { P[b].push_back(i); }b++;
		if (S[i] == 'x') { P[b].push_back(i); }b++;
		if (S[i] == 'y') { P[b].push_back(i); }b++;
		if (S[i] == 'z') { P[b].push_back(i); }b++;
	}
	for (i = 0; i < N; i++) {
		ll b = 0; ll key = 0;
		if (T[i] == 'a') { key = b; }b++;
		if (T[i] == 'b') { key = b; }b++;
		if (T[i] == 'c') { key = b; }b++;
		if (T[i] == 'd') { key = b; }b++;
		if (T[i] == 'e') { key = b; }b++;
		if (T[i] == 'f') { key = b; }b++;
		if (T[i] == 'g') { key = b; }b++;
		if (T[i] == 'h') { key = b; }b++;
		if (T[i] == 'i') { key = b; }b++;
		if (T[i] == 'j') { key = b; }b++;
		if (T[i] == 'k') { key = b; }b++;
		if (T[i] == 'l') { key = b; }b++;
		if (T[i] == 'm') { key = b; }b++;
		if (T[i] == 'n') { key = b; }b++;
		if (T[i] == 'o') { key = b; }b++;
		if (T[i] == 'p') { key = b; }b++;
		if (T[i] == 'q') { key = b; }b++;
		if (T[i] == 'r') { key = b; }b++;
		if (T[i] == 's') { key = b; }b++;
		if (T[i] == 't') { key = b; }b++;
		if (T[i] == 'u') { key = b; }b++;
		if (T[i] == 'v') { key = b; }b++;
		if (T[i] == 'w') { key = b; }b++;
		if (T[i] == 'x') { key = b; }b++;
		if (T[i] == 'y') { key = b; }b++;
		if (T[i] == 'z') { key = b; }
		if (P[key].size() == 0) {
			cout << -1;
			exit(0);
		}
	}
	ll now = -1;
	ll next =0;
	for (i = 0; i < N; i++) {
		ll b = 0; ll key=0;
		if (T[i] == 'a') { key = b; }b++;
		if (T[i] == 'b') { key = b; }b++;
		if (T[i] == 'c') { key = b; }b++;
		if (T[i] == 'd') { key = b; }b++;
		if (T[i] == 'e') { key = b; }b++;
		if (T[i] == 'f') { key = b; }b++;
		if (T[i] == 'g') { key = b; }b++;
		if (T[i] == 'h') { key = b; }b++;
		if (T[i] == 'i') { key = b; }b++;
		if (T[i] == 'j') { key = b; }b++;
		if (T[i] == 'k') { key = b; }b++;
		if (T[i] == 'l') { key = b; }b++;
		if (T[i] == 'm') { key = b; }b++;
		if (T[i] == 'n') { key = b; }b++;
		if (T[i] == 'o') { key = b; }b++;
		if (T[i] == 'p') { key = b; }b++;
		if (T[i] == 'q') { key = b; }b++;
		if (T[i] == 'r') { key = b; }b++;
		if (T[i] == 's') { key = b; }b++;
		if (T[i] == 't') { key = b; }b++;
		if (T[i] == 'u') { key = b; }b++;
		if (T[i] == 'v') { key = b; }b++;
		if (T[i] == 'w') { key = b; }b++;
		if (T[i] == 'x') { key = b; }b++;
		if (T[i] == 'y') { key = b; }b++;
		if (T[i] == 'z') { key = b; }
		if (P[key][P[key].size()-1] <= now) {
			next = P[key][0];
			ans += (M - now) + (next);
			now = next;
		}
		else {
			next = *lower_bound(P[key].begin(), P[key].end(), now+1);
			ans += (next - now);
			now = next;
		}
	}
	cout << ans;
}

Measured memory_bytes: 1724