#include <bits/stdc++.h>
using namespace std;
vector<vector<long long>> a(26);
int main() {
  string s, t;
  cin >> s >> t;
  for (int i = 0; i < s.size(); i++) {
    long long now = s[i] - 'a';
    a[now].push_back(i + 1);
  }
  long long ans = 0, now = 0;
  bool out = false;
  for (int i = 0; i < t.size(); i++) {
    long long sear = t[i] - 'a';
    bool ch = false;
    auto Iter1 = upper_bound(a.at(sear).begin(), a.at(sear).end(), now);
    long long res = Iter1 - a[sear].begin();
    if (res != a[sear].size()) {
      long long fi = a[sear][res];
      ans += fi - now;
      now = fi;
      ch = true;
      out = false;
    }
    if (out) {
      cout << -1;
      return 0;
    }
    if (ch != true) {
      i--;
      ans += s.size() - now;
      now = 0;
      out = true;
    }
  }
  cout << ans;
  return 0;
}
