#include <bits/stdc++.h>
using namespace std;
vector<int> cplaces[26];

int main() {
    string s,t;
    bool ok =1;
    int cur=0,idx,sz;
    long long itaken=0;
    cin>>s>>t;
    int slen = s.length();
    int tlen = t.length();
    for(int i=0;i<slen;i++)
    {
        cplaces[s[i]-'a'].push_back(i+1);
    }
    for(int i=0;i<tlen&&ok;i++)
    {
        sz=cplaces[t[i]-'a'].size();
        if(sz==0){ok=0;break;}
        idx = upper_bound(cplaces[t[i]-'a'].begin(),cplaces[t[i]-'a'].end(),cur)-cplaces[t[i]-'a'].begin();
        if(idx<cplaces[t[i]-'a'].size())
        {
            itaken += cplaces[t[i]-'a'][idx]-cur;
            cur=cplaces[t[i]-'a'][idx];
        }
        else
        {
            itaken += slen-cur;
            cur=0;
            idx = upper_bound(cplaces[t[i]-'a'].begin(),cplaces[t[i]-'a'].end(),cur)-cplaces[t[i]-'a'].begin();
            itaken += cplaces[t[i]-'a'][idx]-cur;
            cur=cplaces[t[i]-'a'][idx];
        }
    }
    if(ok) cout<<itaken<<endl;
    else cout<<-1<<endl;
    return 0;
}
