from bisect import bisect



s = eval(input())

t = eval(input())



d = dict()



for i in range(26):

    d[chr(i+97)] = []



for i, si in enumerate(s):

    d[si].append(i)



ans = 0

res = -1



for i in range(len(t)):

    if d[t[i]] == []:

        print((-1))

        exit()

    index = bisect(d[t[i]], res)

    if index == len(d[t[i]]):

        ans += len(s) - res + d[t[i]][0]

        res = d[t[i]][0]

    else:

        ans += d[t[i]][index] - res

        res = d[t[i]][index]



print(ans)
from bisect import bisect



s = eval(input())

t = eval(input())



if len(set(t) & set(s)) != len(set(t)):

    print((-1))

    exit()



d = dict()



for i, si in enumerate(s):

    if si in d:

        d[si].append(i)

    else:

        d[si] = [i]



ans = 0

res = d[t[0]][0]



for i in range(1, len(t)):

    index = bisect(d[t[i]], res)

    if index == len(d[t[i]]):

        ans += len(s)

        res = d[t[i]][0]

    else:

        res = d[t[i]][index]



ans += res + 1



print(ans)
from bisect import bisect

s = eval(input())
t = eval(input())
d = dict()
for i in range(26):
    d[chr(i + 97)] = []
for i, si in enumerate(s):
    d[si].append(i)
ans = 0
res = -1
for i in range(len(t)):
    if d[t[i]] == []:
        print((-1))
        exit()
    index = bisect(d[t[i]], res)
    if index == len(d[t[i]]):
        ans += len(s) - res + d[t[i]][0]
        res = d[t[i]][0]
    else:
        ans += d[t[i]][index] - res
        res = d[t[i]][index]
print(ans)

from bisect import bisect

s = eval(input())
t = eval(input())
if len(set(t) & set(s)) != len(set(t)):
    print((-1))
    exit()
d = dict()
for i, si in enumerate(s):
    if si in d:
        d[si].append(i)
    else:
        d[si] = [i]
ans = 0
res = d[t[0]][0]
for i in range(1, len(t)):
    index = bisect(d[t[i]], res)
    if index == len(d[t[i]]):
        ans += len(s)
        res = d[t[i]][0]
    else:
        res = d[t[i]][index]
ans += res + 1
print(ans)

+if len(set(t) & set(s)) != len(set(t)): +    print((-1)) +    exit() -for i in range(26): -    d[chr(i + 97)] = [] -    d[si].append(i) +    if si in d: +        d[si].append(i) +    else: +        d[si] = [i] -res = -1 -for i in range(len(t)): -    if d[t[i]] == []: -        print((-1)) -        exit() +res = d[t[0]][0] +for i in range(1, len(t)): -        ans += len(s) - res + d[t[i]][0] +        ans += len(s) -        ans += d[t[i]][index] - res +ans += res + 1