#include <bits/stdc++.h>
    #define hell                         1000000007 
    #define M                            1000000007
    #define Maxi                      10000000000000000
        #define lcm(a,b)                     (a*b)/__gcd(a,b)
        #define ll                           long long

        #define vll                          vector<ll>
        #define vi                           vector<long long>
        #define pll                          vector< pair<ll,ll> >
        #define pb                           push_back
        //#define mp                           make_pair
        #define all(v)                       v.begin(),v.end()
        #define lbnd                         lower_bound
        #define ubnd                         upper_bound
        #define bs                           binary_search
        #define F                            first
        #define S                            second
        #define rep(i,a,b)                   for(i=a;i<b;i++)
        #define parr(a,n)                    for(i=0;i<n;i++) cout<<a[i]<<" ";cout<<endl;
        #define pcont(a)                     for(auto i:a) cout<<i<<" ";cout<<endl;
        #define ret(x)                       return cout<<x,0;
        #define dbg(x)                       cout << #x << " is " << x << endl;
        //#define endl                           '\n'
     
     
        // Debug //
     
        #define trace(x)                 cerr << #x << ": " << x << endl;
        #define trace1(x)                cerr << #x << ": " << x << endl;
        #define trace2(x, y)             cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
        #define trace3(x, y, z)          cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl;
        #define trace4(a, b, c, d)       cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << endl;
        #define trace5(a, b, c, d, e)    cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << endl;
        #define trace6(a, b, c, d, e, f) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << " | " << #f << ": " << f << endl;


    using namespace std;
    
    //ll parent
    vector<ll>graph[200004];
    ll value[200004];
    ll visited[200005];

    ll fun(string s,string t)
    {

      ll i,j;
      ll n,m;
      n=s.size();
      m=t.size();

      map<char,ll>m1;

      for(i=0;i<n;i++)
      {
        m1[s[i]]=1;
      }
      for(i=0;i<m;i++)
      {
        if(m1.find(t[i])==m1.end())
        {
          cout<<-1<<endl;
          return -1;
        }
      }
      return 0;


    }



    int main()
    {

         ios_base::sync_with_stdio(false);
         cin.tie(NULL);cout.tie(NULL);
      
     /*set <ll>st[26];

     string s,t;
     cin>>s>>t;
     if(fun(s,t)==-1)
     {
      return 0;
     }
     ll i,j;
     ll n,m;
     n=s.size();
     m=t.size();

     for(i=0;i<n;i++)
     {
      st[s[i]-'a'].insert(i);
     }

    
     ll sum=0;
     ll pre=-1;
     for(i=0;i<m;i++)
     {
       ll pos;
       pos=*st[t[i]-'a'].lower_bound(pre+1);
       //cout<<i<<" "<<pos<<endl;
        if(pos>pre && pos!=st[t[i]-'a'].size())
        {
          sum+=pos-pre;
          pre=pos;
        }
        else
        {
          //cout<<i<<" fdf d"<<endl;
          pos=*st[t[i]-'a'].lower_bound(0LL);
          sum+=n-1-pre+pos+1;
          pre=pos;
        }

     }

     cout<<sum<<endl;
*/

         ll i,j,n,m,k,cnt=0,ans=0,t=1;
  vll v[26];
  string a,b;
  cin>>a>>b;
  n=a.length(),m=b.length();
  rep(i,0,n) v[a[i]-'a'].pb(i);
  ll pr=-1;
  cnt=0;
  rep(i,0,m){
    k=b[i]-'a';
    if(v[k].empty()) ret(-1)
    ll pos=ubnd(all(v[k]),pr)-v[k].begin();
    if(pos==v[k].size()) cnt++,pr=v[k][0];
    else pr=v[k][pos];
  } 
  ret(cnt*n+pr+1);




      return 0;
  }
        

        
    


  



Measured memory_bytes: 7496