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.List;
import java.util.Scanner;

public class Main {
	static class CharDict{
		List<Integer> pos;
		public CharDict() {
			pos = new ArrayList<Integer>();
		}
		int posArr[];
		void toArray(){
			posArr = new int[pos.size()];
			for(int i = 0 ; i < posArr.length ; ++i){
				posArr[i] = pos.get(i);
			}
		}
		int nextPosition(int currentPosition){
			int last = posArr[posArr.length - 1];
			if(last < currentPosition){
				return posArr[0];
			}
			if(last == currentPosition){
				return currentPosition;
			}
			int insertPoint = Arrays.binarySearch(posArr, currentPosition);
			if(insertPoint >= 0){
				return posArr[insertPoint];
			}
			insertPoint = ~insertPoint;
			return posArr[insertPoint];
		}
	}
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		String t = sc.next();
		CharDict dicts[] = new CharDict[26];
		char sarr[] = s.toCharArray();
		for(int i = 0 ; i < sarr.length ; ++i){
			int c = sarr[i] - 'a';
			if(dicts[c] == null){
				dicts[c] = new CharDict();
			}
			dicts[c].pos.add(i);
		}
		for(CharDict dict : dicts){
			if(dict != null){
				dict.toArray();				
			}
		}
		int N = s.length();
		char tarr[] = t.toCharArray();
		long ret = 0;
		int pos = 0;
		for(int i = 0 ; i < tarr.length ; ++i){
			int c = tarr[i] - 'a';
			if(dicts[c] == null){
				System.out.println(-1);
				return ;
			}
			CharDict dict = dicts[c];
			int nextP = dict.nextPosition(pos);
			if(nextP >= pos){
				ret += nextP - pos + 1;
			}else{
				ret += nextP + N - pos + 1;
			}
//			System.out.println(nextP);
			pos = nextP + 1;
			if(pos == N){
				pos = 0;
			}
		}
		System.out.println(ret);
	}
}
