#include <bits/stdc++.h>
using namespace std;
char s[100050];
char t[100050];
int pos[30];
vector<int> G[30];
int main() {
  scanf("%s%s", s, t);
  long long n = strlen(s);
  long long m = strlen(t);
  for (int i = 0; i < n; i++) {
    G[s[i] - 'a'].push_back(i);
  }
  long long cnt = 0;
  int now = 0;
  for (int i = 0; i < m; i++) {
    int num = t[i] - 'a';
    if (G[num].size() == 0) {
      printf("-1");
      return 0;
    }
    while (pos[num] < G[num].size() && G[num][pos[num]] < now) {
      pos[num]++;
    }
    if (G[num][pos[num]] > now) {
      now = G[num][pos[num]];
      pos[num]++;
    } else {
      cnt++;
      for (int j = 0; j < 26; j++) pos[j] = 0;
      pos[num] = 1;
      now = G[num][0];
    }
  }
  cout << cnt * n + now + 1;
  return 0;
}
