#include <bits/stdc++.h>
using namespace std;
int main() {
  string s, t;
  cin >> s >> t;
  string ls = s + s;
  vector<int> ch[26];
  for (int i = 0; i < (int)(ls.size()); i++) {
    int temp = ls[i] - 'a';
    ch[temp].push_back(i);
  }
  int ans = 0;
  int cur = 0;
  int idx;
  bool notFind = false;
  for (int i = 0; i < (int)(t.size()); i++) {
    int temp = t[i] - 'a';
    if (ch[temp].size() == 0) {
      cout << "-1" << endl;
      return 0;
    } else {
      int idx = 0;
      int pos = ch[temp][idx];
      while (pos < cur) {
        idx++;
        pos = ch[temp][idx];
      }
      if (pos > s.size() - 1) {
        ans += s.size();
        cur = pos - (s.size());
      } else {
        cur = pos;
      }
    }
  }
  ans += cur + 1;
  cout << ans << endl;
  return 0;
}
