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

public class Main {
	static final PrintStream out = System.out;
	static final Scanner sc = new Scanner(System.in);
	static final long Mod = 1000_000_007L;
	public static void main(String[] args) {
		Main main = new Main();
		main.solve();
		System.exit(0);
	}

	void solve() {
		String S1 = next();
		String S2 = next();
		int N = S2.length();
		int SearchTlen = S1.length();
		char[] SearchT = (S1+S1).toCharArray();// search対象の配列
		char[] SearchC = S2.toCharArray();//searchする文字
		List<List<Integer>> list = new ArrayList<>(26);
		for(int i=0;i<26;i++){
			list.add(new ArrayList<>());
		}
		// a = 0, z = 25;
		for(int i=0;i<SearchTlen*2;i++) {
			int t = SearchT[i];
			t-=97;
			list.get(t).add(i);
		}

		long cnt = 1;
		int index = 0;
		int Previous_index = 0;// 前のindex
		for(int l=0;l<N;l++) {
			int t = SearchC[l];
			t-=97;
			if(list.get(t).size()==0) {
				out.println(-1);
				return;
			}
			index = list.get(t).get(BinarySearch(list.get(t),index));

			cnt += index - Previous_index;
			if(index >= SearchTlen) {
				index -= SearchTlen;
			}
			Previous_index = index;
			index++;
		}
		out.println(cnt);
	}
	//二部探索
	static int BinarySearch(List<Integer> a, long k) {
		int l = -1;
		int r = a.size();
		while(r - l > 1) {
			int mid = (r + l) / 2;
			if(a.get(mid) >= k) r = mid;
			else l = mid;
		}
		return r;
	}


	public int[] nextIntArray(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)a[i] = nextInt();
		return a;
	}
	public long[] nextLongArray(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)a[i] = nextLong();
		return a;
	}
	public int nextInt() {
		return Integer.parseInt(next());
	}
	public long nextLong() {
		return Long.parseLong(next());
	}
	public String next() {
		return sc.next();
	}
}