#include <bits/stdc++.h>
using namespace std;
int main() {
  string s, t;
  cin >> s >> t;
  vector<vector<int>> pos(26);
  for (int idx = 0; idx < s.size(); ++idx) pos[s[idx] - 'a'].push_back(idx);
  long long ans = 0LL;
  int x = -1;
  for (int idx = 0; idx < t.size(); ++idx) {
    int c = t[idx] - 'a';
    if (pos[c].empty()) {
      cout << -1 << endl;
      return 0;
    }
    int it = upper_bound(pos[c].begin(), pos[c].end(), x) - pos[c].begin();
    if (pos[c].size() == it) {
      ans += pos[c][0] - x + s.size();
      x = pos[c][0];
    } else {
      ans += pos[c][it] - x;
      x = pos[c][it];
    }
  }
  cout << ans << endl;
  return 0;
}
