// Original C++ solution (slower):
#include <bits/stdc++.h>

using namespace std;



#define all(v)   v.begin(), v.end()

#define endl "\n";

#define pb push_back

#define F first

#define S second

#define JULEE_DO_THE_THING fast()

#define to_str to_string

#define isOdd(n)    (n&1)

#define LLMAX LLONG_MAX

#define LLMIN LLONG_MIN

#define IMIN INT_MIN

#define IMAX INT_MAX

#define pow POW



typedef long long ll;

typedef unsigned long long ull;

typedef long double ld;

typedef double dd;

typedef string str;

typedef vector<int> vecint;

typedef vector<ll> vecll;

typedef pair<int, int> pii;



void fast() {

	cin.tie(0);

	cout.tie(0);

	cin.sync_with_stdio(0);

}



bool compare(int &a, int &b) {

	return a > b;

}



ll numOfDigits(ll n) {

	if (!n)

		return 1;

	return (ll) (log10(n)) + 1;

}



ull POW(ll a, ll b);



/*



 */



ll BN();

int main() {

	JULEE_DO_THE_THING;

	//freopen("test cases\\Strings of Impurity.txt", "r", stdin) ;

	str s, t; cin>>s>>t;

    int n = s.size(), m = t.size();

    map<char, bool> vis;

    for(int i=0; i<n; i++)vis[s[i]] = 1;

    for(int i=0; i<m; i++){

        if(vis.find(t[i])==vis.end())

            return cout<<-1, 0;

    }

    map<char, set<int>> mp;

    t = " " + t; m++;

    for(int i=0; i<n; i++) mp[s[i]].insert(i);

    int index[m+1]={IMAX}; index[m] = IMAX;

    for(int i=1; i<m; i++){

        int up;

        auto it = mp[t[i]].upper_bound(index[i-1]);

        if(it==mp[t[i]].end()) up = *mp[t[i]].begin();

        else up = *it;

        index[i] = up;

    }

    ull subSequnce = 0;

    for(int i=1; i<m; i++){

       if(index[i]<=index[i-1])subSequnce++;

    }

    //cout<<subSequnce<<endl;

    int j = m-1, x;

    while(j>=1 && index[j]<index[j+1]) j--;

    str lastSequence = t.substr(j+1);

    t = t.substr(1); m--;

    ull lastSubLenght  = 0 ;

    for( j=0, x = 0; j<n && x<lastSequence.size(); j++){

       if(s[j]==lastSequence[x])x++;

    }

    lastSubLenght = j;

    //cout<<lastSubLenght<<endl;

    cout<<(subSequnce-1)*s.size() + lastSubLenght;

	return 0;

}



ll BN() {

	ll low = 0;

	ll up = 0;

	ll ans = 0;

	while (low <= up) {

		ll mid = ((low + up) / 2);

		if (mid) {

			ans = mid;

			low = mid + 1;

		} else

			up = mid - 1;

	}

	return ans;

}



ull POW(ll a, ll b) {

	ull res = 1;

	while (b > 0) {

		if (b & 1)

			res = res * a;

		a = a * a;

		b >>= 1;

	}

	return res;

}


// Optimized solution to the same problem (faster):
#include<cstdio>

#include<cstring>

using namespace std;

char s[100005];

char t[100005];

int ind[100005][27];

bool vis1[27],vis2[27];

int main(){

	scanf("%s",s+1);

	scanf("%s",t+1);

	int lens=strlen(s+1);

	int lent=strlen(t+1);

	for(int i=1;i<=lens;i++)

		vis1[s[i]-'a']=1;

	for(int i=1;i<=lent;i++)

		vis2[t[i]-'a']=1;

	for(int i=0;i<26;i++)

		if(vis2[i]&&(!vis1[i])){

			printf("-1\n");

			return 0;

		}

	

	for(int i=lens;i>=1;i--){

		for(int j=0;j<26;j++)

			ind[i][j]=ind[i+1][j];

		ind[i][s[i]-'a']=i;

	}

	int num=0,now=1;

	for(int i=1;i<=lent;i++){

		if(now>lens||!ind[now][t[i]-'a']){

			now=1;

			num++;

		}

		now=ind[now][t[i]-'a']+1;

	}

	now--;

	printf("%lld\n",(long long)num*(long long)lens+(long long)now);

	return 0;

}

// Fastest known solution for this problem: