#dictでよかったかも？

import bisect



s=eval(input())

t=eval(input())



#a,b,cの出てきたところを小さい順にメモ

alp=[[] for i in range(26)]



for i in range(len(s)):

    alp[ord(s[i])-ord("a")].append(i)



#alp[w]の中からnow以降のものを探す．なければ一番手前を．

def bi_search(now,w):

    r=0

    if now>=alp[w][-1]:

        now=-1

        r=1

    ne_i=bisect.bisect_right(alp[w],now)

    ne=alp[w][ne_i]

    return ne,r



    

ans=0

rep=0

now=-1#s上の何文字目か

for i in range(len(t)):

    num=ord(t[i])-ord("a")

    if len(alp[num])==0:

        ans=-1

        break

    now,r=bi_search(now,num)

    rep+=r

if ans==-1:

    print(ans)

else:

    ans=rep*len(s)+now+1

    print(ans)


def I(): return int(eval(input()))

def MI(): return list(map(int, input().split()))

def LI(): return list(map(int, input().split()))



def main():

    import bisect

    

    mod=10**9+7

    s=eval(input())

    t=eval(input())

    

    L=[[]for _ in range(26)]

    

    N=len(s)

    for i in range(N):

        c=ord(s[i])-97

        L[c].append(i)

        

    cur=-1

    rep=0

    

    M=len(t)

    for i in range(M):

        c=ord(t[i])-97

        if len(L[c])==0:

            print((-1))

            exit()

            

        num=bisect.bisect_right(L[c],cur)

        if num>=len(L[c]):

            rep+=1

            num=0

        cur=L[c][num]

        

    ans=N*rep + cur + 1

    print(ans)

        

        

        



main()

# dictでよかったかも？
import bisect

s = eval(input())
t = eval(input())
# a,b,cの出てきたところを小さい順にメモ
alp = [[] for i in range(26)]
for i in range(len(s)):
    alp[ord(s[i]) - ord("a")].append(i)
# alp[w]の中からnow以降のものを探す．なければ一番手前を．
def bi_search(now, w):
    r = 0
    if now >= alp[w][-1]:
        now = -1
        r = 1
    ne_i = bisect.bisect_right(alp[w], now)
    ne = alp[w][ne_i]
    return ne, r


ans = 0
rep = 0
now = -1  # s上の何文字目か
for i in range(len(t)):
    num = ord(t[i]) - ord("a")
    if len(alp[num]) == 0:
        ans = -1
        break
    now, r = bi_search(now, num)
    rep += r
if ans == -1:
    print(ans)
else:
    ans = rep * len(s) + now + 1
    print(ans)

def I():
    return int(eval(input()))


def MI():
    return list(map(int, input().split()))


def LI():
    return list(map(int, input().split()))


def main():
    import bisect

    mod = 10**9 + 7
    s = eval(input())
    t = eval(input())
    L = [[] for _ in range(26)]
    N = len(s)
    for i in range(N):
        c = ord(s[i]) - 97
        L[c].append(i)
    cur = -1
    rep = 0
    M = len(t)
    for i in range(M):
        c = ord(t[i]) - 97
        if len(L[c]) == 0:
            print((-1))
            exit()
        num = bisect.bisect_right(L[c], cur)
        if num >= len(L[c]):
            rep += 1
            num = 0
        cur = L[c][num]
    ans = N * rep + cur + 1
    print(ans)


main()

-# dictでよかったかも？ -import bisect - -s = eval(input()) -t = eval(input()) -# a,b,cの出てきたところを小さい順にメモ -alp = [[] for i in range(26)] -for i in range(len(s)): -    alp[ord(s[i]) - ord("a")].append(i) -# alp[w]の中からnow以降のものを探す．なければ一番手前を． -def bi_search(now, w): -    r = 0 -    if now >= alp[w][-1]: -        now = -1 -        r = 1 -    ne_i = bisect.bisect_right(alp[w], now) -    ne = alp[w][ne_i] -    return ne, r +def I(): +    return int(eval(input())) -ans = 0 -rep = 0 -now = -1  # s上の何文字目か -for i in range(len(t)): -    num = ord(t[i]) - ord("a") -    if len(alp[num]) == 0: -        ans = -1 -        break -    now, r = bi_search(now, num) -    rep += r -if ans == -1: +def MI(): +    return list(map(int, input().split())) + + +def LI(): +    return list(map(int, input().split())) + + +def main(): +    import bisect + +    mod = 10**9 + 7 +    s = eval(input()) +    t = eval(input()) +    L = [[] for _ in range(26)] +    N = len(s) +    for i in range(N): +        c = ord(s[i]) - 97 +        L[c].append(i) +    cur = -1 +    rep = 0 +    M = len(t) +    for i in range(M): +        c = ord(t[i]) - 97 +        if len(L[c]) == 0: +            print((-1)) +            exit() +        num = bisect.bisect_right(L[c], cur) +        if num >= len(L[c]): +            rep += 1 +            num = 0 +        cur = L[c][num] +    ans = N * rep + cur + 1 -else: -    ans = rep * len(s) + now + 1 -    print(ans) + + +main()