// Author -> Preeyadarshee Dev
//
// train hard win easy :D
// nik is love
// nik is motivation
//
// do modulo operations very carefully
// try to avoid binary search, use linear search preferrably to make calculations easier
// always make your custom binary search and watch out for overflows
// read the problems carefully
// never rely on floating point calculation
#include<bits/stdc++.h>
#define mp                    make_pair
#define pb                    push_back
#define ll                    long long
#define ss                       second
#define ff                        first
#define fr(i,a,b)   for(ll i=a;i<b;i++)
#define f(i,n)                fr(i,0,n)
#define rf(i,b,a) for(ll i=b-1;i>=a;i--)
#define r(i,n)                rf(i,n,0)
#define eps                   0.000000000000001
#define sz(a)                int((a).size())
#define all(c)               (c).begin(),(c).end()
#define tr(c,i)              for(typeof(c).begin() i = (c).begin(); i != (c).end(); i++)
#define present(c,x)         ((c).find(x) != (c).end())
#define cpresent(c,x)        (find(all(c),x) != (c).end())
#define pi                   pair<int,int>
#define pll                  pair < ll , ll >
#define endl                 '\n'
#define PI                   3.141592653589793238462643383279502884197169399375105820974944592307816406286
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
typedef vector< int > vi;
typedef vector< vi > vvi;
int dx[8]={1,-1,0,0,-1,-1,1,1};
int dy[8]={0,0,-1,1,-1,1,-1,1};
vector<int> adj[200010],vis(200010,0),dis(200010,0),fin(200010,0);
int myrandom (int i) { return std::rand()%i;}
int t=1;
void dfs(int a)
{
    dis[a]=t;
    t++;
    vis[a]=1;
    for(auto i:adj[a])
    {
        if(vis[i]==0)
        {
            dfs(i);
        }
    }
    fin[a]=t;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s,t;
    cin>>s>>t;
    set<ll> st[26];
    for(int i=0;i<(int)s.length();i++)
    {
        st[s[i]-'a'].insert(i+1);
    }
    ll cnt=0,cur=0;
    for(int i=0;i<(int)t.length();i++)
    {
        auto itr=st[t[i]-'a'].upper_bound(cur);
        if(itr==st[t[i]-'a'].end())
        {
            if(cur)
            {
                cnt=cnt+(ll)s.length();
                cur=0;
                itr=st[t[i]-'a'].upper_bound(cur);
                if(itr==st[t[i]-'a'].end())
                {
                    cout<<-1<<endl;
                    return 0;
                }
                else
                {
                    cur=*itr;
                }
            }
            else
            {
                cout<<-1<<endl;
                return 0;
            }
        }
        else
        {
            cur=*itr;
        }
    }
    cnt=cnt+cur;
    cout<<cnt<<endl;
}
/*int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //ifstream fin;
    //ofstream fout;
    //fin.open("input.txt");
    //fout.open("output.txt");
    int n,q;
    cin>>n>>q;
    for(int i=0;i<n-1;i++)
    {
        int a,b;
        cin>>a>>b;
        adj[a].pb(b);
        adj[b].pb(a);
    }
    vector<ll> ans(n+2,0);
    dfs(1);
    for(int i=0;i<q;i++)
    {
        ll p,x;
        cin>>p>>x;
        ans[dis[p]]+=x;
        ans[fin[p]]-=x;
    }
    for(int i=1;i<=n;i++)
    {
        ans[i]=ans[i]+ans[i-1];
    }
    for(int i=1;i<=n;i++)
    {
        cout<<ans[i]<<" ";
    }
    cout<<endl;
}
*/


Measured memory_bytes: 12240