#include <bits/stdc++.h>
using namespace std;
using lint = long long;
const int INF = 1e9;
const lint LINF = 1e18;
const lint MOD = 1e9 + 7;
const double EPS = 1e-10;
int main() {
  string S, T;
  cin >> S >> T;
  set<char> apearInS{};
  for (auto c : S) {
    apearInS.insert(c);
  }
  for (auto c : T) {
    if (apearInS.count(c) == 0) {
      cout << -1 << endl;
      return 0;
    }
  }
  vector<vector<lint>> NextIndexOf(26, vector<lint>(S.size() + 1, INF));
  for (char c = 'a'; c <= 'z'; c++) {
    int ci = c - 'a';
    for (int i = S.size() - 1; 0 <= i; i--) {
      if (S[i] == c) {
        NextIndexOf[ci][i] = i;
      }
      if (0 < i) NextIndexOf[ci][i - 1] = NextIndexOf[ci][i];
    }
  }
  lint ans = 0LL;
  lint pos = 0;
  for (int i = 0; i < T.size(); i++) {
    pos = NextIndexOf[T[i] - 'a'][pos];
    if (pos == INF) {
      ans += S.size();
      pos = NextIndexOf[T[i] - 'a'][0];
    }
    pos += 1;
    if (pos == S.size()) pos = 0;
  }
  ans += pos;
  cout << ans << endl;
  return 0;
}
