#include <bits/stdc++.h>
using namespace std;
int main(void) {
  string s, t;
  map<char, vector<long long> > c;
  cin >> s >> t;
  long long n = s.length(), cur = 0;
  for (long long(i) = 0; (i) < (n); (i)++) c[s[i]].push_back(i);
  for (char a : t) {
    vector<long long>& v = c[a];
    if (!v.size()) {
      cout << (-1) << endl;
      return 0;
    }
    auto it = lower_bound(v.begin(), v.end(), cur % n);
    (cur = cur / n * n + 1) += it == v.end() ? *(v.begin()) + n : *it;
  }
  cout << (cur) << endl;
  return 0;
}
