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.io.ByteArrayInputStream;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;
import java.util.TreeSet;

public class Main {

	static boolean honban = true;

    public static void main(String[] args) throws Exception {
    	if (honban) {
            Scanner sc = new Scanner(System.in);
            mainInternal(sc);

    	} else {
    		String[] testInputs = {
    				"contest\r\n" +
    				"son",

    				"contest\r\n" +
    				"programming",

    				"contest\r\n" +
    				"sentence"
    		};

    		for (String testInput : testInputs) {
    			Scanner sc = new Scanner(new ByteArrayInputStream(testInput.getBytes()));
    			mainInternal(sc);
    		}
    	}
    }

    public static void mainInternal(Scanner sc) {

    	char[] argS = sc.next().toCharArray();
    	char[] argT = sc.next().toCharArray();

    	// argSの各文字が、配列のどの位置に出てくるかを保存しておく
    	Map<Character, TreeSet<Integer>> charIndexMap = new HashMap<Character, TreeSet<Integer>>();

    	for (int i = 0; i < argS.length; i++) {
    		char c = argS[i];
    		TreeSet<Integer> t = charIndexMap.get(c);

    		if (t == null) {
    			t = new TreeSet<Integer>();
    			charIndexMap.put(c, t);
    		}

    		t.add(i);
    	}

    	// 文字列連結したS'全体において、どのインデックスにいるか
    	long fullGlobalIndex = 1;

    	// 直前のS内のインデックス（S'じゃなくて、S）
    	int prevLocalIndex = -1;

    	for (char c : argT) {

    		// 文字がどの位置に出てくるか？（同じ文字でも複数の個所に出てくる可能性がある）
    		TreeSet<Integer> charIndex = charIndexMap.get(c);

    		if (charIndex == null) {
    			System.out.println("-1");
    			return;
    		}

    		Integer nextLocalIndex = charIndex.higher(prevLocalIndex);

    		if (nextLocalIndex == null) {
    			nextLocalIndex = charIndex.first();

    			fullGlobalIndex += argS.length - prevLocalIndex + nextLocalIndex;
    			prevLocalIndex = nextLocalIndex;

    		} else {
    			if (prevLocalIndex < 0) {
    				prevLocalIndex = 0;
    			}
    			fullGlobalIndex += nextLocalIndex - prevLocalIndex;
    			prevLocalIndex = nextLocalIndex;
    		}
    	}

    	System.out.println(fullGlobalIndex);
    }
}