#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std ;
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define rep(i,a,b) for(int i=a; i<=b; i++)
#define per(i,b,a) for(int i=b; i>=a; i--)
#define sz(v) (int)v.size()
#define len(s) (int)s.length()
#define all(v) v.begin(), v.end()
#define pb push_back
#define fi first
#define se second
typedef pair<int, int> pi ;
typedef vector<pair<int,int> > vpi ;
typedef vector<int> vi ;
typedef long long ll ;
typedef double db ;
typedef long double ldb ;
const int mod = 1e9 + 7;
const int cmod = 998244353 ;
const int inf = 1e8 + 5;
const db cpi = 3.14159265358 ;
ll powmod(ll a, ll b) { ll ret = 1 ; while(b) { if(b&1) ret = (ret*a)%mod ;  a = (a*a)%mod ; b >>= 1 ; }  return ret ; }
const int maxn = 1e5 + 5 ;
string s, t ;
int nxt[maxn][27] ;
int n, m ;
int main()
{
    ios::sync_with_stdio(false) ;
    cin.tie(NULL) ;
    cin >> s >> t ;
    n = len(s) ;
    m = len(t) ;
    set<int> alp[26] ;
    rep(i,0,n-1)
    {
        int x = int(s[i] - 'a') ;
        alp[x].insert(i);
    }
    rep(i,0,n)
    {
        rep(j,0,25)
        {
            nxt[i][j] = -1 ;
        }
    }
    rep(i,0,n-1)
    {
        rep(j,0,25)
        {
            if(!alp[j].empty())
            {
                nxt[i][j] = *alp[j].begin() ;
            }
        }
        int alph = int(s[i] - 'a') ;
        alp[alph].erase(i) ;
    }
    int block = 0 ;
    int cur = 0 ;
    ll res = 0 ;
    int found = 0;
    while(found < m)
    {
        if(block > 1e6) break ;
        int x = int(t[found] - 'a') ;
        int y = nxt[cur][x] ;
        if(y == -1)
        {
            cur = 0 ;
            block++ ;
        }
        else
        {
            cur = y + 1 ;
            found++ ;
        }
        if(found == m) break ;
        if(cur == n)
        {
            block++ ;
            cur = 0 ;
        }
    }
    if(found != m)
    {
        cout << "-1\n" ;
        return 0 ;
    }
    res = n*block + cur ;
    cout << res << "\n" ;
    return 0 ;
}
