#include <iostream>
#include <string>

using namespace std;

int main() {
    string s, t;
    cin >> s;
    cin >> t;

    long long shead = 0;
    long long time = 0;
    for (char x : t) {
        int pos = s.find(x);
        if (pos == -1) {
            cout << -1 << endl;
            return 0;
        }
        int ppos = s.substr(shead).find(x);
        if (ppos == -1) {
            time += 1;
            shead = pos + 1;
        } else {
            shead += ppos + 1;
        }
    }
    cout << (time * s.size() + shead) << endl;
    return 0;
}

    