import sys

input=sys.stdin.readline

import string

import bisect



def main():

    s = input().strip()

    t = input().strip()



    if not all(s.find(c) >= 0 for c in t):

        print((-1))

        exit()

    

    sa = [[] for _ in string.ascii_lowercase]

    ai = ord('a')

    for i,c in enumerate(s):

        sa[ord(c)-ai].append(i+1)

#    print(sa)



    ls = len(s)

    ans = 1 # 条件を満たす整数

    i = 1 # s の何番目の文字から探し始めるか

    for c in t:

        a = sa[ord(c)-ai]

        if len(a) == 0 or i > a[-1]:

            ans += ls-i+1

            i = 1

        bi = bisect.bisect_left(a,i)

        if bi < len(a):

            ans += a[bi]-i+1

            i = a[bi]+1

#        print("c,a,ans,i=", c, a, ans, i)

    print((ans-1))



if __name__ == '__main__':

    main()

import sys

input=sys.stdin.readline

import string

import bisect



def main():



    S = input().strip()

    T = input().strip()

    if any(S.find(c) < 0 for c in T):

        print((-1))

        return



    dS = {c:[] for c in string.ascii_lowercase}

    for i, s in enumerate(S):

        dS[s].append(i)

    

    ans = 0

    pos = 0

    ls = len(S)

    for c in T:

        if dS[c][-1] < pos:

            pos = 0

            ans += ls

        bi = bisect.bisect_left(dS[c], pos)

        pos = dS[c][bi] + 1



    print((ans + pos))



if __name__ == '__main__':

    main()

import sys

input = sys.stdin.readline
import string
import bisect


def main():
    s = input().strip()
    t = input().strip()
    if not all(s.find(c) >= 0 for c in t):
        print((-1))
        exit()
    sa = [[] for _ in string.ascii_lowercase]
    ai = ord("a")
    for i, c in enumerate(s):
        sa[ord(c) - ai].append(i + 1)
    #    print(sa)
    ls = len(s)
    ans = 1  # 条件を満たす整数
    i = 1  # s の何番目の文字から探し始めるか
    for c in t:
        a = sa[ord(c) - ai]
        if len(a) == 0 or i > a[-1]:
            ans += ls - i + 1
            i = 1
        bi = bisect.bisect_left(a, i)
        if bi < len(a):
            ans += a[bi] - i + 1
            i = a[bi] + 1
    #        print("c,a,ans,i=", c, a, ans, i)
    print((ans - 1))


if __name__ == "__main__":
    main()

import sys

input = sys.stdin.readline
import string
import bisect


def main():
    S = input().strip()
    T = input().strip()
    if any(S.find(c) < 0 for c in T):
        print((-1))
        return
    dS = {c: [] for c in string.ascii_lowercase}
    for i, s in enumerate(S):
        dS[s].append(i)
    ans = 0
    pos = 0
    ls = len(S)
    for c in T:
        if dS[c][-1] < pos:
            pos = 0
            ans += ls
        bi = bisect.bisect_left(dS[c], pos)
        pos = dS[c][bi] + 1
    print((ans + pos))


if __name__ == "__main__":
    main()

-    s = input().strip() -    t = input().strip() -    if not all(s.find(c) >= 0 for c in t): +    S = input().strip() +    T = input().strip() +    if any(S.find(c) < 0 for c in T): -        exit() -    sa = [[] for _ in string.ascii_lowercase] -    ai = ord("a") -    for i, c in enumerate(s): -        sa[ord(c) - ai].append(i + 1) -    #    print(sa) -    ls = len(s) -    ans = 1  # 条件を満たす整数 -    i = 1  # s の何番目の文字から探し始めるか -    for c in t: -        a = sa[ord(c) - ai] -        if len(a) == 0 or i > a[-1]: -            ans += ls - i + 1 -            i = 1 -        bi = bisect.bisect_left(a, i) -        if bi < len(a): -            ans += a[bi] - i + 1 -            i = a[bi] + 1 -    #        print("c,a,ans,i=", c, a, ans, i) -    print((ans - 1)) +        return +    dS = {c: [] for c in string.ascii_lowercase} +    for i, s in enumerate(S): +        dS[s].append(i) +    ans = 0 +    pos = 0 +    ls = len(S) +    for c in T: +        if dS[c][-1] < pos: +            pos = 0 +            ans += ls +        bi = bisect.bisect_left(dS[c], pos) +        pos = dS[c][bi] + 1 +    print((ans + pos))