#include <bits/stdc++.h>
const long long mod = 1e9 + 7, inf = 1e9, linf = 1 << 30;
const long long hashmod[4] = {(int)1e9 + 2277, (int)1e9 + 5277, (int)1e9 + 8277,
                              (int)1e9 + 9277};
const long double EPS = 0.000000001L, pi = acos(-1);
using namespace std;
using namespace std;
int cnt[200005];
vector<int> pa[30];
int main() {
  string s;
  string t;
  cin >> s >> t;
  bool x = true;
  for (auto z : s) cnt[z]++;
  for (auto z : t)
    if (!cnt[z]) x = false;
  if (x == false) {
    cout << "-1";
    return 0;
  }
  for (int i = 0; i < s.size(); i++) {
    pa[s[i] - 'a'].push_back(i);
  }
  long long cntt = 0;
  long long res = s.size();
  long long cur = pa[t[0] - 'a'][0];
  for (int i = 1; i < t.size(); i++) {
    int id = t[i] - 'a';
    int l = 0;
    int r = pa[id].size() - 1;
    int ans = pa[id][r];
    if (cur >= ans) {
      ans = pa[id][l];
    } else {
      while (l <= r) {
        int mid = (l + r) >> 1;
        int curmid = pa[id][mid];
        if (curmid > cur) {
          r = mid - 1;
          ans = curmid;
        } else
          l = mid + 1;
      }
    }
    if (ans < cur) {
      cntt++;
    }
    cur = ans;
  }
  long long anss = cntt * 1LL * res + cur + 1;
  cout << anss;
  return 0;
}
