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.HashMap;
import java.util.HashSet;
import java.util.Scanner;
import java.util.TreeMap;
class Main{


	static final int MOD = 1000000007;

	static	ArrayList<TreeNode> tree;
	static HashSet<Integer> set;
	static int[] ans;

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);			//文字の入力
		char[] s = sc.next().toCharArray();
		char[] t = sc.next().toCharArray();
		

		
		TreeMap<Character, ArrayList<Integer>> data = new TreeMap<Character,ArrayList<Integer>>();
		for(int i = 0;i < s.length;i++){				//各文字ごとに出現indexを記録
			char c = s[i];
			ArrayList<Integer> list = data.getOrDefault(c, new ArrayList<Integer>());
			list.add(i);
			data.put(c, list);
		}
		
		long ans = 0;
		int index = -1;
		for(int i = 0;i < t.length;i++){
			char c = t[i];
//		
			int next = lowerbond(index,data.get(c));				//次の文字の位置=現在地よりも上で最小の一
			if(next == -1){
				next = lowerbond(-1,data.get(c));
				ans += s.length;
			}
			if(next == -1){				//不可能
				ans = -1;
				System.out.println(ans);
				return;
			}
			index = next;
			
		}
		
		ans += index+1;
		System.out.print(ans);

	}





	static int upperbond(int k,ArrayList<Integer> data){		//kより小さい最大の値をdataの中から探し、返す二分探索
		if(data == null){
			return -1;
		}
		int max = data.size();
		int min = -1;
//		System.out.println("upper");
//		System.out.println("k "+k);
//		for(int i = 0;i < data.size();i++){
//			System.out.println(data.get(i));
//		}

		
		//		if(min == data.length-1){
		//			if(data[min] > k){
		//				return min;
		//			}
		//		}

		while(max-min > 1){
			int mid = (max+min)/2;
			if(data.get(mid) >= k){
				max = mid;
			}else{
				min = mid;
			}
		}

		
		if(min != -1){
			min = data.get(min);
		}
		
//		System.out.println(max);
		return min;
	}

	static int lowerbond(int k,ArrayList<Integer> data){		//kより大きい最小の値をdataの中から探し、返す二分探索
		if(data == null){
			return -1;
		}
//		System.out.println("lo");
//		System.out.println("lo");
		int max = data.size();
		int min = -1;

		while(max-min > 1){
			int mid = (max+min)/2;
			if(data.get(mid) > k){
				max = mid;
			}else{
				min = mid;
			}
		}

		if(max >= data.size()){				//最大の
			max = -1;
		}else{
			max = data.get(max);
		}
//		System.out.println(max);
		
//		System.out.println(min);
		return max;
	}



	static int gcd(int a,int b){				//最大公約数を返す
		if(b == 0){
			return a;
		}else{
			return gcd(b, a%b);
		}
	}
	static long gcd(long a,long b){
		if(b == 0){
			return a;
		}else{
			return gcd(b, a%b);
		}
	}



	static long lcm (long a, long b) {
		long g = gcd(a,b);
		return a/g*b;
	}




}

class TreeNode{
	int value;
	int sum;
	ArrayList<TreeNode> childlen;

	public TreeNode(int v,int s) {
		this.value = v;
		this.sum = s;
		this.childlen = new ArrayList<TreeNode>();
	}


}


class Edge  implements Comparable{

	int index;
	HashSet<Integer> hen;
	HashSet<Integer> used;
	HashMap<Integer, Integer> map;
	int size;


	public Edge(int index) {
		// TODO 自動生成されたコンストラクター・スタブ
		this.index = index;
		hen = new HashSet();
		used = new HashSet<Integer>();
		map = new HashMap<Integer,Integer>();
	}

	public int compareTo(Object other) {
		Edge otherpair = (Edge)other;

		return   otherpair.hen.size() - hen.size();
	}
}

class Pair implements Comparable{
	int from;
	int end;
	public Pair(int from,int end) {
		this.from = from;
		this.end = end;
		// TODO 自動生成されたコンストラクター・スタブ
	}

	@Override
	public int compareTo(Object other) {
		Pair otherpair = (Pair)other;

		return  from - otherpair.from;
	}








}




