#include <bits/stdc++.h>
using namespace std;
using ull = unsigned long long;
using ld = long double;
using ll = long long;
ll gcd(ll m, ll n) {
  if (n == 0) return abs(m);
  return (gcd(n, m % n));
}
void putYN(bool b) {
  if (b) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}
void swap(ll &a, ll &b) {
  ll tmp = a;
  a = b;
  b = tmp;
}
ll combi(ll n, ll k) {
  ll r = 1, rr = 1;
  for (ll i = 0; i < k; ++i) {
    r *= (n - i);
    rr *= (i + 1);
  }
  r /= rr;
  return r;
}
int main() {
  string s, t;
  cin >> s >> t;
  map<char, vector<ll>> nummap;
  for (ll i = 0; i < s.size(); ++i) {
    ;
    if (nummap.find(s[i]) == nummap.end()) {
      nummap[s[i]] = vector<ll>();
    }
    auto itr = lower_bound(nummap[s[i]].begin(), nummap[s[i]].end(), i);
    nummap[s[i]].insert(itr, i);
  }
  for (ll i = 0; i < t.size(); ++i) {
    if (nummap.find(t[i]) == nummap.end()) {
      cout << -1 << endl;
      return 0;
    }
  }
  ll min_ = LLONG_MAX;
  {
    ll re = 0;
    ll num = -1;
    for (ll i = 0; i < t.size(); ++i) {
      vector<ll> &v = nummap[t[i]];
      auto numi = lower_bound(v.begin(), v.end(), num + 1);
      if (numi == v.end()) {
        re++;
        num = v[0];
      } else {
        num = *(numi);
      }
    }
    ll m = re * s.size() + num + 1;
    if (m < min_) min_ = m;
  }
  cout << min_ << endl;
  return 0;
}
