import sys

input = sys.stdin.readline

sys.setrecursionlimit(10 ** 7)



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:

        x = -2

        break

    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] - y + LS

    x = next_x



print((x + 1))



# E - Strings of Impurity  maspyさん

import sys

input = sys.stdin.readline

sys.setrecursionlimit(10 ** 7)



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 #今みたところ　次は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)

    

    



import sys

input = sys.stdin.readline
sys.setrecursionlimit(10**7)
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:
        x = -2
        break
    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] - y + LS
    x = next_x
print((x + 1))

# E - Strings of Impurity  maspyさん
import sys

input = sys.stdin.readline
sys.setrecursionlimit(10**7)
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  # 今みたところ　次は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)

+# E - Strings of Impurity  maspyさん -x = -1 +x = -1  # 今みたところ　次はx+1から -        x = -2 -        break +        print((-1)) +        exit() -        next_x = (x + 1) + arr[0] - y + LS +        next_x = (x + 1) + arr[0] + LS - y -print((x + 1)) +ans = x + 1 +print(ans)