#

import itertools
from collections import Counter
from collections import defaultdict
from collections import deque
import bisect
from heapq import heappush, heappop
import sys
sys.setrecursionlimit(1000000000)

def solve(positions, s, t):
    # print('{}, s = {}, t = {}'.format(positions, s, t))
    if len(t) == 0:
        return 0

    if len(positions[t[0]]) == 0:
        return -1

    i = 0
    j = 0
    while i < len(s) and j < len(t):
        candidates = positions[t[j]]
        pos = bisect.bisect_left(candidates, i)
        if pos == len(candidates):
            break

        i = candidates[pos] + 1
        j += 1

    if j == len(t):
        return i
    else:
        rest = solve(positions, s, t[j:])
        return len(s) + rest if rest != -1 else -1


def main():
    s = input()
    t = input()

    positions = defaultdict(list)
    for i in range(len(s)):
        positions[s[i]].append(i)

    print(solve(positions, s, t))


if __name__ == '__main__':
    main()
