#include <bits/stdc++.h>
using namespace std;
void Suhaib_Sawalha() {
  string s, w;
  cin >> s >> w;
  set<int> st[26];
  set<int>::iterator it;
  int n = s.size();
  for (int i = 0; i < n; ++i) st[s[i] - 'a'].insert(i + 1);
  for (char &c : w) {
    if (st[c - 'a'].empty()) {
      cout << -1;
      return;
    }
  }
  int last = 0;
  long long ans = 0;
  for (char &c : w) {
    it = st[c - 'a'].upper_bound(last);
    if (it == st[c - 'a'].end()) {
      ++ans;
      it = st[c - 'a'].begin();
    }
    last = *it;
  }
  cout << ans * 1ll * (long long)n + 1ll * last;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  Suhaib_Sawalha();
  return 0;
}
