#include <bits/stdc++.h>
using namespace std;
int sz[26];
vector<int> pos[26];
int main() {
  string str;
  cin >> str;
  for (int i = 0; i < str.size(); i++) {
    pos[str[i] - 'a'].push_back(i + 1);
  }
  string t;
  cin >> t;
  long long ans = 0;
  int prev = 0;
  for (char c : t) {
    if (pos[c - 'a'].size() == 0) {
      printf("-1");
      return 0;
    } else {
      int cur_idx =
          lower_bound(pos[c - 'a'].begin(), pos[c - 'a'].end(), prev) -
          pos[c - 'a'].begin();
      if (cur_idx == pos[c - 'a'].size()) {
        cur_idx = pos[c - 'a'][0];
      } else {
        cur_idx = pos[c - 'a'][cur_idx];
      }
      if (cur_idx <= prev) {
        ans += str.size() - prev + cur_idx;
      } else {
        ans += (cur_idx - prev);
      }
      prev = cur_idx;
    }
  }
  printf("%lld", ans);
}
