/*
                    !!!!!!                                                     
                    !!!!!!!!!!                                                 
                     !!!!!!!!!!!!!!!                                           
                       !!!!!!!!!!!!!!                                          
                     !!!!!!!!!!!!!!!                                           
                      !!!!!!!!!!!!                                             
                      !!!!!!!!!!!!                                             
                        !!!!!!!!!!!!                                           
                        !!!!!!!!                                               
                        !!!!!!!!!!                                             
                       !!!!!!!!!!!!!!                                          
                     !!!!!!!!!!!!!!!!                                          
                    !!!!!!!!!!!!!!!!                                  !!!!!    
                  !!!!!!!!!!!!!!!!!!!                               !!!!!!!!!! 
                 !!!!!!!!!!!!!!!!!!!!!!!                 !         !!!!!!!!!!  
            !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!              !!     !!!!!!!!!!!!    
           !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!        !!      !!!!!!!!       
            !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!      
             !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !!!!!!!!!!!!       
              !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!  !!!!!!!!!!!!       
       !!!!!! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!        !!!!!!        
      !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!      !!!!!         
          !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!        !!!          
        !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!        !          
          !!!!!! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!                       
           !!!!! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!                         
                  !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!                          
                 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!                           
                  !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!                               
                  !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!                               
                  !!!!!!!!!!!!!!!!!!!!!!!!!!!!                                 
                  !!!!!!!!!!!!!!!!!!!!!!!!!!                                   
                  !!!!!!!!!!!!!!!!!!!!!!!!!                                    
                   !!!!!!!!!!!!!!!!!!!!!!!!                                    
                    !!!!!!!!!!!!!!!!!!!!                                       
                    !!!!!!!!!!!!!!!!!!!                                        
                     !!!!!!!!!!!!!!!!                                          
                      !!!!!!!!!!!!!!!!                                         
                      !!!!!!!!!!!!!!!                                          
                       !!!!!!!!!!!!!!                                          
                        !!!!!!!!!!!!                                           
                        !!!!!!!!!!!!                                           
                        !!!!!!!!!!!!                                           
                          !!!!!!!!                                             
                          !!!!!!                                               
                           !!!! 
*/                                               
#include <bits/stdc++.h>
#define MAXN 200005
#define mod 1000000007
#define inf LLONG_MAX/3
using namespace std;
/*
 *  author  :  vivekcrux
 */
typedef long long ll; 
typedef pair<ll,ll> pll;

ll power(ll x,ll y,ll m=mod)
{
  ll ans = 1;
  while(y>0)
  {
    if(y&1)
    {
      ans = (ans*x)%m;
    }
    x = (x*x)%m;  
    y /= 2;
  }
  return ans%m;
}

ll modInverse(ll a, ll m=mod) 
{ 
    ll m0 = m; 
    ll y = 0, x = 1; 
  
    if (m == 1) 
      return 0; 
  
    while (a > 1) 
    { 
        // q is quotient 
        ll q = a / m; 
        ll t = m; 
  
        // m is remainder now, process same as 
        // Euclid's algo 
        m = a % m, a = t; 
        t = y; 
  
        // Update y and x 
        y = x - q * y; 
        x = t; 
    } 
  
    // Make x positive 
    if (x < 0) 
       x += m0; 
  
    return x; 
} 

vector<ll> tree[MAXN],val,vis;

void dfs(int n)
{
    vis[n] = true;
    for(auto it: tree[n])
    {
        if(!vis[it])
        {
            val[it] += val[n];
            dfs(it);
        }
    }
}

ll iss(string s,string t)
{
    int i,j;
    for(i=0,j=0;i<s.length();i++)
    {
        if(s[i]==t[j])
        {
            j++;
            if(j==t.length())
                return i+1;
        }
    }
    return false;
}

int main()
{
  // freopen("input.txt","r",stdin);

  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  ll t;
  // cin>>t;
  t = 1;
  while(t--)
  {
    ll n,m,i,j,ans=LONG_MAX;
    string s,rs;
    cin>>s>>rs;
    n = s.length();
    m = rs.length();
    map<char,vector<ll>> pos;
    map<char,ll> cs,cr;
    i = 0;
    for(auto it: s)
    {
        cs[it]++;
        pos[it].push_back(i);
        i++;
    }
    for(auto it: rs)
    {
        cr[it]++;
    }
    for(i='a';i<='z';i++)
    {
        if(cs[i]==0 && cr[i]>0)
        {
            cout<<"-1";
            return 0;
        }
    }
    ll k = 2;
    i = -1;
    for(j=0;j<m;j++)
    {
        // cout<<rs[j]<<" "<<pos[rs[j]][lower_bound(pos[rs[j]].begin(),pos[rs[j]].end(),i%n)-pos[rs[j]].begin()]<<" ";
        if(*pos[rs[j]].rbegin()>(i%n))
            i += pos[rs[j]][upper_bound(pos[rs[j]].begin(),pos[rs[j]].end(),i%n)-pos[rs[j]].begin()]-i%n;
        else
            i += n-(i%n-pos[rs[j]][upper_bound(pos[rs[j]].begin(),pos[rs[j]].end(),-1)-pos[rs[j]].begin()]);
        // cout<<i<<":"<<s[i%n]<<" ";
    }
    cout<<i+1;
  }
  return 0;
}


Measured memory_bytes: 6352