#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  string s, t;
  cin >> s >> t;
  vector<long long> v[26];
  for (int i = 0; i < s.length(); i++) {
    v[s[i] - 'a'].push_back(i + 1);
  }
  long long cur = 0, sl = s.length();
  int c = 0;
  for (int i = 0; i < t.length(); i++) {
    int id = (t[i] - 'a');
    long long temp = 2e18;
    if (v[id].size() == 0) {
      cur = -1;
      break;
    }
    if (cur == 0) {
      cur = v[id][0];
      continue;
    }
    if (t[i] == t[i - 1])
      c++;
    else
      c = 0;
    if (c == v[id].size()) c = 0;
    long long tm = (cur - v[id][c]) / sl + 2ll;
    cur = v[id][c] + (tm - 1) * sl;
  }
  cout << cur;
  return 0;
}
