/********************/
/* K B G D E L T A */
/*     DA-IICT      */
/********************/
 
#include<bits/stdc++.h>
using namespace std;
using   ll=long long;
using   ld=long double;
#define fast           ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define endl           "\n"
#define F(i,n)         for(ll i=0;i<n;i++)
#define rep(i,a,b)     for(ll i=a;i<b;i++)
#define repp(i,a,b)    for(ll i=a;i>=b;i--)
#define pb             push_back
#define mp             make_pair
#define vll            vector<ll>
#define f              first
#define s              second
#define pll            pair<ll,ll>
#define ALL(v)         v.begin(),v.end()
#define ALLR(v)        v.rbegin(),v.rend()
#define pii            3.14159265358979323
#define mod            1000000007
 
void solve()
{
    ll ans=0,tt=0;

    string s,t;

    cin>>s>>t;

    vector<vector<ll>> a(26);

    for(int i=0;i<s.size();i++)
    {
        a[s[i]-'a'].pb(i);
    }

    ll it;

    for(int i=0;i<t.size();i++)
    {
        it=lower_bound(ALL(a[t[i]-'a']),tt)-a[t[i]-'a'].begin();

        if(it==a[t[i]-'a'].size())
        {
            ans+=s.size();

            tt=0;

            it=lower_bound(ALL(a[t[i]-'a']),tt)-a[t[i]-'a'].begin();

            if(it==a[t[i]-'a'].size())
            {
                cout<<-1;

                return;
            }
        }

        tt=a[t[i]-'a'][it]+1;
    }

    ans+=tt;

    cout<<ans<<endl;
}
 
signed main(){
 
    fast;
 
    ll t=1;
 
    //cin>>t;
 
    while(t--)
    {
        solve();
    }
 
    return 0;
}
