#include <bits/stdc++.h>
using namespace std;
map<char, vector<int>> mp;
string s, t;
int solve();
int make_map();
int main() {
  cin >> s;
  cin >> t;
  make_map();
  solve();
}
int make_map() {
  for (int i = 0; i < s.size(); i++) {
    mp[s.at(i)].push_back(i);
  }
  return 0;
}
int solve() {
  long score = 0;
  vector<int> buf;
  int length = s.size();
  int now = -1;
  for (int i = 0; i < t.size(); i++) {
    buf = mp[t.at(i)];
    if (buf.size() == 0) {
      score = -1;
      break;
    }
    for (int j = 0; j < buf.size(); j++) {
      if (now < buf.at(j)) {
        score = (score / length) * length + buf.at(j) + 1;
        now = buf.at(j);
        break;
      } else {
        if (j == buf.size() - 1 || j > 0) {
          score = (score / length + 1) * length + buf.at(0) + 1;
          now = buf.at(0);
          break;
        }
      }
    }
  }
  cout << score << endl;
  return 0;
}
