#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vvl = vector<vl>;
using vb = vector<bool>;
using vs = vector<string>;
using pll = pair<ll, ll>;
const ll oo = 0x3f3f3f3f3f3f3f3fLL;
const double eps = 1e-9;
int main() {
  cin.sync_with_stdio(0);
  string s, t;
  map<char, vl> sm;
  cin >> s >> t;
  for (ll i = (0); i < (s.size()); i++) {
    sm[s[i]].push_back(i);
  }
  ll r = 0, i = 0;
  vl sv;
  for (char c : t) {
    try {
      sm.at(c);
    } catch (...) {
      cout << "-1\n";
      return 0;
    }
  }
  for (char c : t) {
    sv = sm.at(c);
    if (sv.back() < i) {
      r += 1;
      i = sv.front();
    } else {
      auto next = lower_bound(sv.begin(), sv.end(), i);
      i = *next;
    }
  }
  cout << r * s.size() + i + 1 << "\n";
}
