Given are two strings s and t consisting of lowercase English letters. Determine if there exists an integer i satisfying the following condition, and find the minimum such i if it exists.

* Let s' be the concatenation of 10^{100} copies of s. t is a subsequence of the string {s'}_1{s'}_2\ldots{s'}_i (the first i characters in s').

Constraints

* 1 \leq |s| \leq 10^5
* 1 \leq |t| \leq 10^5
* s and t consists of lowercase English letters.

Input

Input is given from Standard Input in the following format:


s
t


Output

If there exists an integer i satisfying the following condition, print the minimum such i; otherwise, print `-1`.

Examples

Input

contest
son


Output

10


Input

contest
programming


Output

-1


Input

contest
sentence


Output

33

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Scanner;
import java.util.Set;

public class Main {
    public static void main(final String[] args) {
        final Scanner scanner = new Scanner(System.in);
        final String s = scanner.nextLine();
        final String t = scanner.nextLine();

        final Set<Character> sSet = new HashSet<>();
        final Set<Character> tSet = new HashSet<>();

        for (final char c : s.toCharArray()) {
            sSet.add(c);
        }

        for (final char c : t.toCharArray()) {
            tSet.add(c);
        }

        if (!sSet.containsAll(tSet)) {
            System.out.println(-1);
            return;
        }

        final Map<Character, List<Integer>> map = new HashMap<>();
        for (int i = 0; i < s.length(); i++) {
            map.computeIfAbsent(s.charAt(i), e -> new ArrayList<>()).add(i);
        }

        long counter = 0;
        int currentIndex = -1;
        for (int i = 0; i < t.length(); i++) {
            final List<Integer> indexList = map.get(t.charAt(i));
            final int indexInIndexes = extendedBinarySearch(indexList, currentIndex);
            if (indexInIndexes == indexList.size()) {
                counter++;
                currentIndex = indexList.get(0);
            } else {
                currentIndex = indexList.get(indexInIndexes);
            }

        }

        System.out.println(counter * s.length() + 1 + currentIndex);
    }

    @SuppressWarnings("unchecked")
    private static int extendedBinarySearch(final Object indexes, final int value) {
        final int rawIndex;
        if (indexes instanceof int[]) {
            rawIndex = Arrays.binarySearch((int[]) indexes, value);
        } else {
            rawIndex = Collections.binarySearch((List<Integer>) indexes, value);
        }

        if (rawIndex >= 0) {
            return rawIndex + 1;
        }

        return -(rawIndex + 1);
    }
}
