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

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		String s = sc.next();
		String t = sc.next();
		
		List<List<Integer>> alp = new ArrayList<>();
		
		for(int i = 0 ; i < 26 ;i++) {
			alp.add(new ArrayList<>());
		}
		
		for(int i = 0 ;i < s.length() ;i++) {
			int id = s.charAt(i)-'a';
			alp.get(id).add(i);
		}
		
		
		for(int i = 0 ; i < t.length(); i++) {
			int p = t.charAt(i)-'a';
			if(alp.get(p).isEmpty()) {
				System.out.println(-1);
				return;
			}
		}
		
		int f = -1;
		int len = 1;
		
		for(int i = 0 ; i < t.length() ; i++) {
			int p = t.charAt(i)-'a';
			int q = binary_search(alp.get(p),f);
			if(q == -1) {
				len++;
				f = alp.get(p).get(0);
			}
			else {
				f = q;
			}			
		}
		
		long ans = (long)(len-1) * s.length() + f+1;
		System.out.println(ans);
		

	}
	
	static int binary_search(List<Integer> alp, int f) {
		
		int l = 0;
		int r = alp.size()-1;
		int mid =(l+r)/2;
		
		
		if(alp.get(r) <= f) {
			return -1;
		}
		if(alp.get(0) > f) {
			return alp.get(0);
		}
		
		while(r-l > 1) {
			mid = (l+r)/2;
			
			if(alp.get(mid) > f) {
				r = mid; 
			}
			else if(alp.get(mid) < f) {
				l = mid;
			}
			else {
				return alp.get(mid+1);
			}
		}
		return alp.get(r);
		
	}
	
}
