#include <bits/stdc++.h>
const int N = 1e5 + 7;
char s[N], t[N];
int lens, lent;
using ll = long long;
ll ans = 0, last = 0;
std::vector<int> ref[200];
int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  std::cin >> (s + 1) >> (t + 1);
  lens = strlen(s + 1), lent = strlen(t + 1);
  for (int i = 1; i <= lens; i++) ref[s[i]].push_back(i);
  ans = lens;
  for (int i = 1; i <= lent; i++) {
    if (ref[t[i]].empty()) {
      std::cout << -1;
      exit(0);
    }
    auto pos = std::upper_bound(ref[t[i]].begin(), ref[t[i]].end(), last);
    if (pos == ref[t[i]].end()) {
      ans += lens;
      i--;
      last = 0;
    } else
      last = *pos;
  }
  std::cout << ans - (lens - last);
  exit(0);
}
