from collections import defaultdict

from bisect import bisect_left



S = input().rstrip()

T = input().rstrip()



LS = len(S)

index = defaultdict(list)



for i, s in enumerate(S):

  index[s].append(i)

  

x = -1

for t in T:

  arr = index[t]

  if len(arr) == 0:

    print((-1))

    exit()

  y = (x+1)%LS

  i = bisect_left(arr, y)

  if i < len(arr):

    next_x = (x+1) + arr[i] - y

  else:

    next_x = (x+1) + arr[0] + LS - y

  x = next_x

ans = x+1

print(ans)
from collections import defaultdict

from bisect import *

 

S = input().rstrip()

T = input().rstrip()

 

LS = len(S)

index = defaultdict(list)

 

for i, s in enumerate(S):

  index[s].append(i)



x = -1

loop = 0

for t in T:

  arr = index[t]  

  if len(arr) == 0:

    print((-1))

    exit()  

  i = bisect(arr, x)  

  if i == len(arr):

    loop += 1

    x = arr[0]

  else:

    x = arr[i]



print((loop*LS+x+1))
from collections import defaultdict
from bisect import bisect_left

S = input().rstrip()
T = input().rstrip()
LS = len(S)
index = defaultdict(list)
for i, s in enumerate(S):
    index[s].append(i)
x = -1
for t in T:
    arr = index[t]
    if len(arr) == 0:
        print((-1))
        exit()
    y = (x + 1) % LS
    i = bisect_left(arr, y)
    if i < len(arr):
        next_x = (x + 1) + arr[i] - y
    else:
        next_x = (x + 1) + arr[0] + LS - y
    x = next_x
ans = x + 1
print(ans)

from collections import defaultdict
from bisect import *

S = input().rstrip()
T = input().rstrip()
LS = len(S)
index = defaultdict(list)
for i, s in enumerate(S):
    index[s].append(i)
x = -1
loop = 0
for t in T:
    arr = index[t]
    if len(arr) == 0:
        print((-1))
        exit()
    i = bisect(arr, x)
    if i == len(arr):
        loop += 1
        x = arr[0]
    else:
        x = arr[i]
print((loop * LS + x + 1))

-from bisect import bisect_left +from bisect import * +loop = 0 -    y = (x + 1) % LS -    i = bisect_left(arr, y) -    if i < len(arr): -        next_x = (x + 1) + arr[i] - y +    i = bisect(arr, x) +    if i == len(arr): +        loop += 1 +        x = arr[0] -        next_x = (x + 1) + arr[0] + LS - y -    x = next_x -ans = x + 1 -print(ans) +        x = arr[i] +print((loop * LS + x + 1))