#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
template <class T>
using VEC = std::vector<T>;
template <class T>
using MAT = std::vector<std::vector<T>>;
void DUMP() { cerr << endl; }
template <class Head, class... Tail>
void DUMP(Head &&head, Tail &&...tail) {
  cerr << head << ", ";
  DUMP(std::move(tail)...);
}
template <typename T>
ostream &operator<<(ostream &os, vector<T> &vec) {
  os << "{";
  for (auto v : vec) os << v << ",";
  os << "}";
  return os;
}
template <typename T>
ostream &operator<<(ostream &os, set<T> &s) {
  os << "{";
  for (auto p : s) os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, map<T1, T2> &m) {
  os << "{";
  for (auto p : m) os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, pair<T1, T2> p) {
  os << "[" << p.first << " " << p.second << "]";
  return os;
}
VEC<VEC<int>> pos('z' - 'a' + 1);
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  string S, T;
  cin >> S >> T;
  VEC<int> cnt('z' - 'a' + 1, 0);
  for (long long i = (0); i < (long long)('z' - 'a' + 1); ++i) {
    cnt[S[i] - 'a']++;
  }
  VEC<int> cntT('z' - 'a' + 1, 0);
  for (long long i = (0); i < (long long)('z' - 'a' + 1); ++i) {
    cntT[T[i] - 'a']++;
  }
  for (long long i = (0); i < (long long)(S.length()); ++i) {
    if (cntT[S[i] - 'a']) pos[S[i] - 'a'].reserve(cnt[S[i] - 'a']);
  }
  for (long long i = (0); i < (long long)(S.length()); ++i) {
    pos[S[i] - 'a'].push_back(i);
  }
  LL loopnum = 0;
  int prevpos = -1;
  for (long long i = (0); i < (long long)(T.length()); ++i) {
    if (pos[T[i] - 'a'].size() == 0) {
      cout << -1 << endl;
      return 0;
    }
  }
  VEC<int> poslist;
  for (long long i = (0); i < (long long)(T.length()); ++i) {
    poslist = pos[T[i] - 'a'];
    if (prevpos >= poslist[poslist.size() - 1]) {
      loopnum++;
      prevpos = poslist[0];
      continue;
    }
    int newpos = *upper_bound(poslist.begin(), poslist.end(), prevpos);
    prevpos = newpos;
  }
  LL ans = loopnum * S.length() + prevpos + 1;
  printf("%lld\n", ans);
  return 0;
}
