#include <bits/stdc++.h>
int A[26][100000] = {0}, pos[26] = {0};
int main() {
  int l, i, tmp, ex, cur, j;
  long long int loop = 0;
  char s[100000], t[100000];
  scanf("%s", s);
  scanf("%s", t);
  l = strlen(s);
  for (i = 0; i < l; i++) {
    tmp = s[i] - 'a';
    A[tmp][pos[tmp]] = i;
    pos[tmp]++;
  }
  cur = -1;
  for (i = 0; i < strlen(t); i++) {
    tmp = t[i] - 'a';
    ex = 0;
    if (pos[tmp] == 0) {
      printf("-1\n");
      return 0;
    }
    for (j = 0; j < pos[tmp]; j++) {
      if (A[tmp][j] > cur) {
        ex = 1;
        cur = A[tmp][j];
        break;
      }
    }
    if (ex) continue;
    cur = A[tmp][0];
    loop++;
  }
  printf("%lld\n", loop * strlen(s) + cur + 1);
  return 0;
}
